我将尝试使用一些特定样式来为我的UWP应用程序进行样式设计,而在其他平台上应该保持默认样式。
这是我的项目布局:
在
这是我的项目布局:
我尝试了以下事情:
在 Clients.Shared
中创建如下样式:
<Style x:Key="SomeStyle" TargetType="Button" />
在
Clients.Themes.UWP
中添加相同的样式键以覆盖它,但没有成功。然后我尝试创建一个虚拟样式并使用onPlatform
,但这也没有起作用,但我仍然认为这是正确的方法。我有以下代码:<Style x:Key="DummyStyle" TargetType="Button">
<Setter Property="Style">
<Setter.Value>
<OnPlatform x:Key="ButtonStyle" x:TypeArguments="Style">
<On Platform="UWP" Value="{StaticResource SomeStyle}"></On>
</OnPlatform>
</Setter.Value>
</Setter>
</Style>
我尝试过使用合并的ResourceDictionary.MergedDictionaries
,但是我无法包含xaml。
有人有任何线索吗?
OnPlatform
中的Android
等属性标记为过时。有什么替代方案吗? - Savage<OnPlatform><<On Platform="Android" Value=.../></OnPlatform>
的讨论。在C#中,使用switch (Device.RuntimePlatform)
代替。 - ToolmakerSteve