Aga*_*gat 3 xaml styles cross-platform xamarin.forms
当基本标签样式设置为某些特定字体系列时,我需要在某些标签(例如)中将(重置)字体样式设置为默认值。IE:
<Style TargetType="Label">
<Setter Property="FontFamily" Value="{StaticResource ThinFontFamily}" />
</Style>
<Style TargetType="Label" x:Key="MyCustomStyle">
<Setter Property="FontFamily" Value="... to some default"></Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
当然,还有另外两种方法:显式定义所有标签并使用自定义渲染器,但这就像很多代码。
平台默认字体系列可以在样式设置器属性中设置为空值:
<Style x:Key="defaultLabel" TargetType="Label">
<Setter Property="FontFamily" Value="" />
</Style>
...
<Label x:Name="label" Style="{StaticResource defaultLabel}"
Text="{Binding Source={x:Reference label},
Path=Font, StringFormat='Default: {0}'}}" />
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4215 次 |
最近记录: |