如何将 XAML 内的 FontAttributes 设置为粗体和斜体?

How to set FontAttributes within XAML to both Bold and Italic?

在Xamarin.Forms中,如何将XAML中的FontAttributes设置为粗体斜体[=21] =]?

示例:

  <Style TargetType="Label">
    <Setter Property="FontAttributes" Value="Bold" />
    <Setter Property="FontAttributes" Value="Italic" />
  </Style>

在值字段中继续使用逗号分隔它们。

<Style TargetType="Label">
    <Setter Property="FontAttributes" Value="Bold, Italic"/>
  </Style>

务必查看 http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/fonts/

<Style TargetType="Label">
  <Setter Property="FontAttributes" Value="Bold, Italic" />
</Style>

FontAttributes是一个Flag,所以可以传多个值。

如果有人正在寻找代码隐藏解决方案:

element.FontAttributes = FontAttributes.Bold | FontAttributes.Italic;