我有与Xamarin格式的FormattedText绑定有关的问题 参见下面的代码参考
<Label HeightRequest="40" FormattedText="{Binding CustomContent}" Style="{StaticResource SmallTextStyle}" TextColor="{StaticResource FadedTextColor}" HorizontalOptions="StartAndExpand" VerticalOptions="Center" LineBreakMode="TailTruncation"/>
ViewModel--
public class CustomerViewModel : BaseViewModel
{
private FormattedString _customContent;
public FormattedString CustomContent
{
get { return _customContent; }
set { SetProperty(ref _customContent, value); }
}
public CustomerViewModel()
{
CustomContent = new FormattedString
{
Spans =
{
new Span { Text = "Text1", FontSize=14 },
new Span { Text = "Test2 ", FontSize=12, },
new Span { Text = "Test3", FontSize=12, },
}
};
}
}
可以请大家建议正确的答案