2017-08-02 47 views
1

我有这样的风格:如何在样式资源中包含OnPlatform?

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

我想包括此。可能吗?

<Button.FontSize> 
    <OnPlatform x:TypeArguments="x:Double" iOS="25" Android="20" /> 
</Button.FontSize> 

回答

3

定义每个属性为OnPlatform

<OnPlatform x:Key="MyFontSize" x:TypeArguments="x:Double" iOS="14" Android="14" WinPhone="14" /> 

,并指它在YOUT按钮样式像

<Style x:Key="MyButtonStyle" TargetType="{x:Type Button}"> 
    <Setter Property="FontSize" Value="{StaticResource MyFontSize}" /> 
</Style> 
相关问题