我可以通过将值传递给OnIdiom元素来为不同的设备更改字体大小。但是如何将FontSize Medium传递给xaml中的OnIdiom,传入的TypeArguments是什么。
<Style x:Name="normalFont">
<Setter Property="FontSize">
<Setter.Value>
<OnIdiom.Phone>
<OnPlatform x:TypeArguments="x:Double" iOS="Small" Android="Small" />
</OnIdiom.Phone>
<OnIdiom.Tablet>
<OnPlatform x:TypeArguments="x:Double" iOS="Medium" Android="Medium" />
</OnIdiom.Tablet>
</Setter.Value>
</Setter>
</Style>
我知道它不应该是我应该放什么类型的两倍。
放
X:TypeArguments = “NamedSize”
代替
X:TypeArguments = “X:双击”
我在Xaml.cs文件中使用附加的xaml在Constructor中添加了这个
if (Device.Idiom == TargetIdiom.Phone)
{
normalFont.FontSize=Device.GetNamedSize(NamedSize.Small,typeof(Style));
}
else if (Device.Idiom == TargetIdiom.Tablet)
{
normalFont.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Style));
}