I have a bunch of Buttons in my application which look almost the same. The only difference between them is the path data that they use.
This is the style I have for the “minimize button” of my application:
<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>
As you can see, I’m basically just changing the control template to use a path instead of the default button stuff. But this declaration is only for the minimize button – I have a few other buttons, such as “maximize”, “restore” and “close” to deal with now. The problem is that the styles for those buttons will be identical, with the only difference being the Data attribute of their Paths.
What would you recommend me to do to use as little code as possible?
User control?
http://www.codeguru.com/cpp/data/data-misc/xml/article.php/c12521/
http://www.codeproject.com/KB/WPF/XSButton.aspx