I have overriden tabitem template and created my own custom style. however, I'm not sure how to write event triggers for mouse over event.
Sorry for the late response, I am not getting a notification for comments (maybe this should be changed?). Ok, i will try to explain this further. I am not adding comment because i need to post example code. Let's say you have a control, any control. Let's say you have also defined a number of brushes as resources. So:
<LinearGradientBrush x:Key="NormalGradientBrush">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="Red" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="NormalForeground">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="Gray" Offset="1" />
</LinearGradientBrush>
<LinearGradientBrush x:Key="MouseOverGradientBrush">
<GradientStop Color="Red" Offset="0" />
<GradientStop Color="Green" Offset="0.2" />
<GradientStop Color="Black" Offset="1" />
</LinearGradientBrush>
<RadialGradientBrush x:Key="MouseOverForeground" GradientOrigin="0.3,0.5">
<GradientStop Color="Gray" Offset="0" />
<GradientStop Color="Black" Offset="1" />
</RadialGradientBrush >
Now let's say you have the tab item control:
<LinearGradientBrush x:Key="MouseOverGradientBrush">
<GradientStop Color="Black" Offset="0" />
<GradientStop Color="Red" Offset="1" />
</LinearGradientBrush>
<Style x:Key="StyleTabItem"
TargetType="{x:Type TabItem}">
<Setter Property="Foreground"
Value="{StaticResource NormalForeground}" />
<Setter Property="BorderBrush"
Value="Black" />
<Setter Property="Background"
Value="{StaticResource NormalGradientBrush}" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid SnapsToDevicePixels="true">
<Border x:Name="Bd"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="1,1,1,0"
Padding="{TemplateBinding Padding}">
<ContentPresenter x:Name="Content"
HorizontalAlignment="Center"
VerticalAlignment="Center"
SnapsToDevicePixels="True"
ContentSource="Header"
RecognizesAccessKey="True" />
</Border>
</Grid>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver"
Value="true">
// what here?
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
So the question is, how can i tell wpf to do a 3 second animation from the current brush to MouseOverGradientBrush and from the current foreground to MouseOverForeground on the MouseOver Event? I have seen in examples that you do that by changing offsets of gradient one by one. I do now want that. It increases the size of code and can end up being very messy. Besides brushes might have different number of offsets or one can be linear and the other one radial. I hope this is clearer.