Answer the question
In order to leave comments, you need to log in
How to make sure that you do not rewrite the trigger for different WPF elements?
There is such a trigger that changes the color of the rectangle during the OnMouseEnter and OnMouseLeave events:
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Button.MouseEnter">
<BeginStoryboard>
<Storyboard>
<ColorAnimation To="Black" Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" FillBehavior="HoldEnd" Duration="0:0:0.5"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
<EventTrigger RoutedEvent="Button.MouseLeave">
<BeginStoryboard>
<Storyboard>
<ColorAnimation To="#CC001774" Storyboard.TargetProperty="(Rectangle.Fill).(SolidColorBrush.Color)" FillBehavior="HoldEnd" Duration="0:0:0.5"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question