Ala*_*an2 3 xamarin xamarin.forms
我有这种风格:
<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>
Run Code Online (Sandbox Code Playgroud)
我想包括这个.可能吗?
<Button.FontSize>
<OnPlatform x:TypeArguments="x:Double" iOS="25" Android="20" />
</Button.FontSize>
Run Code Online (Sandbox Code Playgroud)
小智 19
使用新的 Xamarin OnPlatform 规范,可以直接在style标签中定义平台样式:
<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>
Run Code Online (Sandbox Code Playgroud)
将每个属性定义为OnPlatform
<OnPlatform x:Key="MyFontSize" x:TypeArguments="x:Double" iOS="14" Android="14" WinPhone="14" />
Run Code Online (Sandbox Code Playgroud)
并按照你的按钮样式引用它
<Style x:Key="MyButtonStyle" TargetType="{x:Type Button}">
<Setter Property="FontSize" Value="{StaticResource MyFontSize}" />
</Style>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1616 次 |
| 最近记录: |