2012-03-06 52 views

回答

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>