【问题标题】:How can I cut the end of the text of a label with HTML format如何使用 HTML 格式剪切标签文本的结尾
【发布时间】:2021-06-23 07:46:53
【问题描述】:

我在一些测试中验证了仅使用TextType 作为Text,我可以从最后的标签中剪切文本。

我想知道是否有任何方法可以在 HTML 格式的文本中完成此操作。

<Label Text="{Binding message}"
       TextType="Html"
       LineBreakMode="TailTruncation"
       HorizontalOptions="StartAndExpand"
       Style="{StaticResource LabelStyle}"/>

【问题讨论】:

    标签: html xaml xamarin.forms label truncation


    【解决方案1】:

    您可以将文本与下面的 html 字符串绑定。

     public string message { get; set; }
        public MainPage()
        {
            InitializeComponent();
            message = "This is <strong>HTML</strong> text.";
    
            this.BindingContext = this;
        }
    

    【讨论】:

    • 知道了。问题是该文本是从系统另一部分的表单发送的,人们可以使用 HTML 或不使用 HTML 发送它。所以我把它作为默认的 HTML 类型
    • 如果此回复对您有帮助,请不要忘记接受它作为答案。谢谢~
    猜你喜欢
    • 2021-04-04
    • 2016-03-03
    • 2015-05-11
    • 1970-01-01
    • 1970-01-01
    • 2013-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多