如何对Xamarin.Forms中的样式应用惯用语过滤
我打算用我的Xamarin.Forms应用程序支持平板电脑,所以我检查了如何创建不同的布局 根据,我可以在XAML代码中使用如何对Xamarin.Forms中的样式应用惯用语过滤,xamarin.forms,xamarin.forms-styles,Xamarin.forms,Xamarin.forms Styles,我打算用我的Xamarin.Forms应用程序支持平板电脑,所以我检查了如何创建不同的布局 根据,我可以在XAML代码中使用OnIdiom开关,如下所示: <Grid.RowSpacing> <OnIdiom x:TypeArguments="x:Double" Phone="10" Tablet="20"/> </Grid.RowSpacing> <Style x:Key="BoldFiel
OnIdiom
开关,如下所示:
<Grid.RowSpacing>
<OnIdiom x:TypeArguments="x:Double"
Phone="10"
Tablet="20"/>
</Grid.RowSpacing>
<Style x:Key="BoldField" TargetType="Label">
<Setter Property="FontAttributes" Value="<OnIdiom x:TypeArguments="FontAttribute" Phone="Bold" Tablet="Normal"/>" />
</Style>
<Style x:Key="BoldField" TargetType="Label">
<Setter Property="FontAttributes">
<Setter.Value>
<OnIdiom x:TypeArguments="FontAttribute" Phone="Bold" Tablet="Normal"/>
</Setter.Value>
</Setter>
</Style>
但是,我还打算创建样式,以尽量减少要编写的代码。不幸的是,我无法使用切换惯用语指定样式值,如下所示:
<Grid.RowSpacing>
<OnIdiom x:TypeArguments="x:Double"
Phone="10"
Tablet="20"/>
</Grid.RowSpacing>
<Style x:Key="BoldField" TargetType="Label">
<Setter Property="FontAttributes" Value="<OnIdiom x:TypeArguments="FontAttribute" Phone="Bold" Tablet="Normal"/>" />
</Style>
<Style x:Key="BoldField" TargetType="Label">
<Setter Property="FontAttributes">
<Setter.Value>
<OnIdiom x:TypeArguments="FontAttribute" Phone="Bold" Tablet="Normal"/>
</Setter.Value>
</Setter>
</Style>
我可以创建一种切换成语的风格吗?我想,你可以。试着这样做:
<Grid.RowSpacing>
<OnIdiom x:TypeArguments="x:Double"
Phone="10"
Tablet="20"/>
</Grid.RowSpacing>
<Style x:Key="BoldField" TargetType="Label">
<Setter Property="FontAttributes" Value="<OnIdiom x:TypeArguments="FontAttribute" Phone="Bold" Tablet="Normal"/>" />
</Style>
<Style x:Key="BoldField" TargetType="Label">
<Setter Property="FontAttributes">
<Setter.Value>
<OnIdiom x:TypeArguments="FontAttribute" Phone="Bold" Tablet="Normal"/>
</Setter.Value>
</Setter>
</Style>
我想,你可以。试着这样做:
<Grid.RowSpacing>
<OnIdiom x:TypeArguments="x:Double"
Phone="10"
Tablet="20"/>
</Grid.RowSpacing>
<Style x:Key="BoldField" TargetType="Label">
<Setter Property="FontAttributes" Value="<OnIdiom x:TypeArguments="FontAttribute" Phone="Bold" Tablet="Normal"/>" />
</Style>
<Style x:Key="BoldField" TargetType="Label">
<Setter Property="FontAttributes">
<Setter.Value>
<OnIdiom x:TypeArguments="FontAttribute" Phone="Bold" Tablet="Normal"/>
</Setter.Value>
</Setter>
</Style>
这太明显了,但我想不出来:)谢谢,它起作用了。这太明显了,但我想不出来:)谢谢,它起作用了