为什么下面的样式不起作用?我在其他地方有完全相同的结构,不同的控制,它的工作。
使用
TargetType="{x:Type Separator}"
而不是
TargetType="Separator"
也不管用。不动
Style
在XAML层次结构的上部。我能避免使用
x:Key="styleName"
和
Style="{StaticResource styleName}"
?
但更重要的是,我试图理解为什么这样的风格绑定并不总是有效。
<ToolBar Height="25">
<ToolBar.Resources>
<Style TargetType="Separator">
<Setter Property="Margin" Value="15"/>
</Style>
<Style TargetType="RadioButton">
<Setter Property="Margin" Value="10"/>
<Setter Property="Width" Value="50"/>
</Style>
</ToolBar.Resources>
<RadioButton Content="A"/> <!-- NOT APPLIED HERE -->
<Separator/> <!-- NOT APPLIED HERE -->
<RadioButton Content="B"/> <!-- NOT APPLIED HERE -->
</ToolBar>