我有两种风格,几乎相同:
<Style x:Key="CancelButtonStyle" TargetType="{x:Type Button}" >
<!-- gigantic common code -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<!-- more common code -->
<Path Data="DIFFERENT_VALUE_A"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="OkButtonStyle" TargetType="{x:Type Button}" >
<!-- gigantic common code -->
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<!-- more common code -->
<Path Data="DIFFERENT_VALUE_B"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
我想提取通用代码(“样式模板”),然后像这样使用它:
<Style x:Key="OkButtonStyle" Base="PathButtonStyle" PathData="DIFFERENT_VALUE_B" />
编辑:正如我在标题中指定的,我不想创建自己的控件