继承默认的Button样式

时间:2013-11-08 12:04:19

标签: windows-store-apps winrt-xaml

我想继承并改变默认按钮的样式,但无法弄清楚如何。

使用:

<Style x:Key="MyBasicButtonStyle" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}"></Style>

不起作用,它说"Type" cannot be used in Windows Store App project ....

1 个答案:

答案 0 :(得分:1)

你可以这样做:

<Style x:Key="BaseStyle" TargetType="Button">
    <Setter Property="Background" Value="Yellow" />
    ...
</Style>

<Style x:Key="InheritedStyle" TargetType="Button" BasedOn="{StaticResource BaseStyle}">
    <Setter Property="Foreground" Value="Red" />
    ...
</Style>