Xamarin.Forms - HTML tag on Label using resx file

后端 未结 1 723
悲&欢浪女
悲&欢浪女 2021-01-28 12:09

Is it possible use HTML tags in resx file and use it as text of label? I tried to use Some text but not working. The tags are print

1条回答
  •  长情又很酷
    2021-01-28 12:52

    With Xamarin.Forms v4.3 and above your label can directly host HTML tags and work something like for instance

    When you check the Microsoft documents you will see:

    Label label = new Label
    {
        Text = "This is HTML text.",
        TextType = TextType.Html
    };
    

    In the example above, the double-quote characters in the HTML have to be escaped using the \ symbol.

    In XAML, HTML strings can become unreadable due to additionally escaping the < and > symbols:

    Alternatively, for greater readability, the HTML can be inlined in a CDATA section

    
    

    In this example, the Label.Text property is set to the HTML string that's inlined in the CDATA section. This works because the Text property is the ContentProperty for the Label class.

    The following screenshots show a Label displaying HTML:

    NOTE: Displaying HTML in a Label is limited to the HTML tags that are supported by the underlying platform.

    Also just tested with Resx and that works too!

    0 讨论(0)
提交回复
热议问题