问题描述
我正在尝试将Xamarin表单标签的TextType属性设置为HTML。当我按如下所示设置此属性时,在运行时会收到错误消息,
“无法解析来自typeref的令牌0100011b的类型(程序集中的预期类'Xamarin.Forms.TextType'...”
我也无法将TextType设置为Text。我犯了同样的错误。如何将标签的TextType设置为HTML?
代码:
var lbl = new Label();
lbl.TextType = TextType.Html;
版本信息: Xamarin Forms 4.3.0
解决方法
您可以尝试
C#:
Label label = new Label{
Text = "This is <strong style=\"color:red\">HTML</strong> text.",TextType = TextType.Html};
XAML:
<Label Text="This is <strong style="color:red">HTML</strong> text."
TextType="Html" />
或
<Label TextType="Html">
<Label.Text>
<h1>Hello World!</h1><br/>SecondLine
</Label.Text>