我是WPF的新手。我不知道如何做到這一點。如何在控件模板資源中重用定義的樣式
我有這個樣式定義 -
<Style TargetType="{x:Type Button}" x:Key="StandardButton">
<Setter Property="Background" Value="{StaticResource LightBackground}"/>
<Setter Property="Foreground" Value="{StaticResource Foreground}"/>
</Style>
我有一個控制模板 -
<ControlTemplate x:Key="ExpanderTemplate" TargetType="{x:Type Expander}">
<ControlTemplate.Resources>
<Style TargetType="{x:Type Button}" /* Here I need to put above defined style */></Style>
</ControlTemplate.Resources>
</ControlTemplate>
我可以做到這一點,但我有很多其他控件來引用此按鈕樣式。我還舉了一個例子。風格有很多代碼,我不能把它作爲每個控件的資源。我想在資源目錄 – user2039445 2013-02-18 07:15:58
中的任何地方引用它,所以你想要所有的按鈕都有這種風格? – 2013-02-18 07:18:11
更新了我認爲你正在尋找的答案。 – 2013-02-18 07:29:45