我的窗口里有一些扩展器...... 我希望当我的Expander扩展时它的标题背景改变了...... 我该怎么做?
答案 0 :(得分:2)
<Style x:Key="ExpanderStyle" TargetType="{x:Type Expander}">
<Style.Triggers>
<Trigger Property="IsExpanded" Value="True">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<Border Background="Green">
<ContentControl Content="{Binding}"/>
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsExpanded" Value="False">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<Border Background="Red">
<ContentControl Content="{Binding}"/>
</Border>
</DataTemplate>
</Setter.Value>
</Setter>
</Trigger>
</Style.Triggers>
</Style>