在WPF中,我用以下代码覆盖基本控制样式:
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Padding" Value="5" />
<Setter Property="Margin" Value="{StaticResource margin}" />
</Style>在UWP中,x:Type In XAMl已经消失了。那么,如何在UWP中完成上述代码呢?谢谢。
发布于 2015-11-06 12:45:27
根据我从文档收集到的信息,通用Windows不再支持x:Type。
为了绕过样式继承,您需要创建一个具有x:Key的基本样式,这可以使用BasedOn属性的StaticResource标记引用。
<Style x:Key="BasicButtonStyle" TargetType="Button">
... (This may contain nothing)
</Style>
<Style TargetType="Button"
BasedOn="{StaticResource BasicButtonStyle}">
...
</Style>发布于 2015-11-06 08:59:35
应该是这样的:
<Style TargetType="Button">
<Setter Property="Padding" Value="5" />
<Setter Property="Margin" Value="{StaticResource margin}" />
</Style>https://stackoverflow.com/questions/33562864
复制相似问题