x:UWP中缺少类型-如何覆盖基本控件样式? [英] x:Type missing in UWP - How override base control style?
本文介绍了x:UWP中缺少类型-如何覆盖基本控件样式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在WPF中,我使用以下代码覆盖基本控件样式:
in WPF I override the basic control styles with the following Code:
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Padding" Value="5" />
<Setter Property="Margin" Value="{StaticResource margin}" />
</Style>
在UWP中,XAMl中的 x:Type
离开了。那么如何在UWP中完成上述代码呢?谢谢。
In UWP the x:Type
in XAMl is gone. So how can I accomplish the above code in UWP? Thanks.
推荐答案
从文档, x:Type
在通用Windows Apps中不再受支持。
From what I can gather from the documentation, x:Type
is no longer supported in Universal Windows Apps.
要避开样式继承,您将需要创建一个具有 x:Key
的基本样式,可以使用 BasedOn
属性的 StaticResource
标记进行引用。
To get around style inheritance, you will need to create a base style which has an x:Key
, this can be referenced using the StaticResource
markup for the BasedOn
property.
<Style x:Key="BasicButtonStyle" TargetType="Button">
... (This may contain nothing)
</Style>
<Style TargetType="Button"
BasedOn="{StaticResource BasicButtonStyle}">
...
</Style>
这篇关于x:UWP中缺少类型-如何覆盖基本控件样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文