我有一堆
Button
在我的应用程序中,看起来几乎相同。它们之间唯一的区别是它们使用的路径数据。
这是我的应用程序的“最小化按钮”的样式:
<Style x:Key="MinimizeButton" TargetType="{x:Type Button}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<!-- The border is here to make the entire "block" clickable.
Without it, only the actual path is clickable. -->
<Border Background="Transparent">
<Path Name="ThePath" Data="{StaticResource MinimizeIconPath}" Style="{StaticResource WindowButtonPath}"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
如您所见,我基本上只是更改了控件模板,以使用路径,而不是默认的按钮内容。但这份声明是
仅限最小化按钮
–我还有一些其他的按钮,比如“最大化”、“恢复”和“关闭”,现在可以处理。问题是这些按钮的样式
完全相同的
唯一的区别是
Data
他们的属性
Path
S.
为了尽可能少地使用代码,您建议我做什么?