如何使用 HTML 格式剪切标签文本的末尾

问题描述

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

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

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

解决方法

您可以使用如下所示的 html 字符串绑定文本。

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

        this.BindingContext = this;
    }

enter image description here