我的整个应用程序的按钮样式如下所示:
<Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
some style code here
</Style>
它会影响每个使用的按钮:
<Button />
但是当我想改变一个像这样的特定按钮时:
<Button>
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="Visibility" Value="Visible"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SomeBoolean}" Value="false">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
它是Windows标准风格。
答案 0 :(得分:1)
您缺少BasedOn
属性:
<Button>
<Button.Style>
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="Visibility" Value="Visible"/>
<Style.Triggers>
<DataTrigger Binding="{Binding SomeBoolean}" Value="false">
<Setter Property="Visibility" Value="Hidden"/>
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>