How can I include an OnPlatform in a style resource?

Viewed 4564

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>
2 Answers

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>
Related