0
我創建了一個按鈕。我的基本要求是圓厚的邊框,與一個以上的顏色(即,買入/賣出按鈕)WPF模板繼承
我希望我可以一次創建模板,並不僅僅是覆蓋邊框刷是這樣的:
<Style x:Key="BorderButton">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Button}">
<Border BorderThickness="2"
BorderBrush="Red"
CornerRadius="3"
Background="{x:Null}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style x:Key="GreenBorderButton" BasedOn="{StaticResource BorderButton}" TargetType="{x:Type Button}">
<Setter Property="BorderBrush" Value="Green" />
</Style>
但他們都產生相同的風格。 我是否需要每次寫出整個模板?看起來像不必要的代碼重複(尤其是如果需要3-4種顏色)。希望有一些方法來繼承模板。
這是偉大的感謝。 是否可以將TemplateBinding應用於其他屬性,例如GradientStop?例如,創建一個漸變按鈕模板,但是操作哪兩種顏色適用於它? – 2010-07-08 15:43:08