I have this style:
<Style x:Key="pointButton" TargetType="Button">
<Setter Property="BorderColor" Value="#999999"/>
<Setter Property="BorderWidth" Value="1" />
<Setter Property="TextColor" Value="#AAAAAA" />
<Setter Property="FontAttributes" Value="Bold" />
<Setter Property="HorizontalOptions" Value="FillAndExpand" />
<Setter Property="VerticalOptions" Value="StartAndExpand" />
<Setter Property="Margin" Value="10,10,10,10" />
<Setter Property="HeightRequest" Value="40" />
</Style>
I would like to include this. Is it possible?
<Button.FontSize>
<OnPlatform x:TypeArguments="x:Double" iOS="25" Android="20" />
</Button.FontSize>
With the new Xamarin OnPlatform specification is possible to define the platform styles directly in the style tag:
<Style x:Key="buttonStyle" TargetType="Button">
<Setter Property="FontSize">
<OnPlatform x:TypeArguments="x:Double">
<On Platform="Android">40</On>
<On Platform="iOS">10</On>
</OnPlatform>
</Setter>
</Style>
Define every property as OnPlatform
<OnPlatform x:Key="MyFontSize" x:TypeArguments="x:Double" iOS="14" Android="14" WinPhone="14" />
and refer it in yout button style like
<Style x:Key="MyButtonStyle" TargetType="{x:Type Button}">
<Setter Property="FontSize" Value="{StaticResource MyFontSize}" />
</Style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With