如何在Xamarin Forms xaml文件中为跨平台设置FontFamily?

时间:2016-07-20 17:40:51

标签: c# xaml xamarin xamarin.forms

我的代码风格是abc.xaml.cs:

    Style labelHeadingStyle = new Style(typeof(Label))
    {
        Setters = {
            new Setter { Property = Label.TextColorProperty, Value = Color.Black  },
            new Setter { Property = Label.FontFamilyProperty, Value = Device.OnPlatform (
                "SomeFont",
                "SomeFont",
                @"/Assets/Fonts/SomeFont.ttf#SomeFont"
            )  },
            new Setter { Property = Label.FontAttributesProperty, Value = FontAttributes.Bold  },
            new Setter { Property = Label.FontSizeProperty, Value = 36 }
        }
    };

在xaml:

<ResourceDictionary>
  <Style x:Key="labelHeadingStyle" TargetType="Label">
    <Setter Property="TextColor" Value="Black" />
    <Setter Property="FontSize" Value="36" />
    <Setter Property="FontFamily" Value="" />
  </Style>
</ResourceDictionary>

我如何在xaml中定义FontFamil,就像我在后面的代码中所做的那样(在C#中)?

0 个答案:

没有答案