【问题标题】:How to set FontAttributes within XAML to both Bold and Italic?如何将 XAML 中的 FontAttributes 设置为粗体和斜体?
【发布时间】:2015-10-02 21:37:20
【问题描述】:

在 Xamarin.Forms 中,如何将 XAML 中的 FontAttributes 设置为 粗体斜体

示例:

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

【问题讨论】:

    标签: xaml xamarin.forms


    【解决方案1】:
    <Style TargetType="Label">
      <Setter Property="FontAttributes" Value="Bold, Italic" />
    </Style>
    

    FontAttributes 是一个标志,所以你可以传递多个值。

    【讨论】:

      【解决方案2】:

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

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

      【讨论】:

        【解决方案3】:

        只需在值字段中使用逗号分隔它们即可。

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

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

        【讨论】:

        猜你喜欢
        • 2011-06-10
        • 2011-07-06
        • 2014-04-29
        • 2012-12-06
        • 2011-03-03
        • 2023-03-29
        • 1970-01-01
        • 2016-08-10
        相关资源
        最近更新 更多