我想创建一个可以应用于不同控件类型的样式。类似于这样:
<ToolBar>
<ToolBar.Resources>
<Style TargetType="Control">
<Setter Property="Margin" Value="1"/>
<Setter Property="Padding" Value="0"/>
</Style>
</ToolBar.Resources>
<ComboBox .../>
<Button .../>
</ToolBar>
希望应用到 ComboBox
和 Button
。但是它并不像我在这里写的那样工作。
有没有可能只针对这些类的祖先元素进行目标定位,例如 Control
?如果不行,应该怎样最好地将通用设置应用于一组控件?