Trigger in Template in WPF
I'm creating a Template for TabItem of TabControl.
So, I need to create Different background dependent on TabItem.IsSelectedProperty and IsMouseOver as well..
So, here is my part of code:
<Window.Resources>
<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Border BorderBrush="Gray" BorderThickness="1" CornerRadius="6,6,0,0" Margin="-2,0,0,0" Cursor="Hand">
<Border.Style>
<Style>
<Style.Triggers>
<Trigger Property="TabItem.IsSelected" Value="False">
<Setter Property="Border.Background" Value="ColorIneed"/>
</Trigger>
<Trigger Property="TabItem.IsSelected" Value="True">
开发者_StackOverflow中文版 <Setter Property="Border.Background" Value="ColorIneed"/>
</Trigger>
<Trigger Property="Border.IsMouseOver" Value="True">
<Setter Property="Border.Background" Value="ColorIneed"/>
</Trigger>
</Style.Triggers>
</Style>
</Border.Style>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
So, here it is, but it works only on Border.IsMouseOver event...
just have a look at this post.
WPF TabItem Header Styling
精彩评论