Xaml Xamarin.Forms为平台设置特定样式

Xaml Xamarin.Forms为平台设置特定样式,xaml,xamarin.forms,themes,xamarin.forms-styles,Xaml,Xamarin.forms,Themes,Xamarin.forms Styles,我试图用一些特定的样式来设计我的UWP应用程序,而在其他平台上它应该保持默认 这是我的项目布局: 我试过以下方法: 在Clients.Shared中创建如下样式: <Style x:Key="SomeStyle" TargetType="Button" /> 我试着在mergedResourceDictionary.MergedDictionaries中混日子,但在那里我无法包含xaml 有人有任何线索吗?为什么不使用 <Button.Style> <O

我试图用一些特定的样式来设计我的UWP应用程序,而在其他平台上它应该保持默认

这是我的项目布局:

我试过以下方法: 在
Clients.Shared中创建如下样式:

<Style x:Key="SomeStyle" TargetType="Button" />
我试着在merged
ResourceDictionary.MergedDictionaries
中混日子,但在那里我无法包含xaml

有人有任何线索吗?

为什么不使用

<Button.Style>
    <OnPlatform x:TypeArguments="x:Style">
        <OnPlatform.iOS>...</OnPlatform.iOS>
        <OnPlatform.Android>...</OnPlatform.Android>
        <OnPlatform.WinPhone>...</OnPlatform.WinPhone>
    </OnPlatform>
</Button.Style>

...
...
...
希望它能有所帮助。

试试这个:

<OnPlatform x:TypeArguments="Color" Android="Green" iOS="White" WinPhone="White"
        x:Key="PrimaryColor" />


<Style x:Key="ButtonColor" TargetType="Button">
    <Setter Property="BackgroundColor" Value="{StaticResource PrimaryColor}" />
</Style>

<Button Text="Hello" HorizontalOptions="StartAndExpand"
   Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource ButtonColor}" />

在本例中,我为一个名为
ButtonColor
的按钮定义了一种样式。该按钮将在所有平台上使用白色背景色,Android除外,该按钮为绿色


我发现这是这个标签最常用的样式;如果您使用的是字体,请确保在模拟器和实际设备上运行,以获得所需的字体。

问题是我无法加载样式:)仅用于颜色,我需要完整的样式Visual Studio将
平台上的
Android
etc属性标记为过时。你知道替代品是什么吗?
<OnPlatform x:TypeArguments="Color" Android="Green" iOS="White" WinPhone="White"
        x:Key="PrimaryColor" />


<Style x:Key="ButtonColor" TargetType="Button">
    <Setter Property="BackgroundColor" Value="{StaticResource PrimaryColor}" />
</Style>

<Button Text="Hello" HorizontalOptions="StartAndExpand"
   Grid.Row="2" Grid.ColumnSpan="2" Style="{StaticResource ButtonColor}" />