Reputation: 8405
I can change the font size by passing values to OnIdiom Element for different device. But how do I pass FontSize Medium to the OnIdiom in xaml, what is the TypeArguments to passed into.
<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>
I know it won't be double what type should I put.
Upvotes: 1
Views: 1759
Reputation: 11
This could be a work around:
<Style x:Key="normalFont" TargetType="Label">
<Setter Property="FontSize" Value="{OnIdiom Phone=Small, Tablet=Medium}" />
</Style>
Upvotes: 0
Reputation: 1
Here you can see how you must do it.
Basically, you must create a MarkupExtension to handle the conversion.
Upvotes: 0
Reputation: 71
I did it in Xaml.cs file attached with xaml in Constructor add this
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));
}
Upvotes: 1
Reputation: 720
put
x:TypeArguments="NamedSize"
instead of
x:TypeArguments="x:Double"
Upvotes: 0