我是一名 WPF 初学者,我有点想弄清楚为什么 XAML 下面没有做我认为应该做的事情:
<ToolBar HorizontalAlignment="Left" Margin="255,250,0,0" VerticalAlignment="Top">
<ToolBar.Resources>
<Style TargetType="{x:Type Separator}">
<Setter Property="Margin" Value="4,6" />
</Style>
</ToolBar.Resources>
<Button Content="Save"/>
<Button Content="Cancel"/>
<Separator />
<Button Content="Options"/>
</ToolBar>
这应该会导致<Separator />
具有 的边距,4,6
但只有在我明确指定x:Key
样式和<Separator Style="..." />
.
从我目前学到的知识来看,我的<Style TargetType="{x:Type Separator}">
应该适用于所有的分隔符<ToolBar>
,它的子元素,它的子元素等等。
我做错了什么?