2010-02-02 54 views
0

我有一堆Button s在我的应用程序中看起来几乎相同。它们之间的唯一区别是它们使用的路径数据。WPF:按钮,这是一个路径

这是我对我的应用程序的“最小化按钮”的作风:

<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> 

正如你所看到的,我基本上只是改变控件模板使用路径,而不是默认的按钮东东。但是,这个声明是只适用于最小化按钮 –我有几个其他按钮,如“最大化”,“恢复”和“关闭”现在处理。问题在于这些按钮的样式将是相同的,唯一的区别是其PathData属性。

你会推荐我做些什么来使用尽可能少的代码?

回答