I want all buttons to blink for 5 seconds when they are clicked.
I try to do it via a style that applies to all buttons (do I need to refer to the style when I declare buttons in xaml or does the style automatically apply to all buttons?)
I can make the
Foreground
change color but what I want is that the background behind the Text of the button changes color not the text itself.I currently have a
ColorAnimation
but I want the button background to blink by alternating between two colors, I do not want the whole color spectrum to be displayed.
I have the following code so far. Can someone please help me in the right direction?
Edit
If animating the button background is tougher to animate then I can easily settle with the foreground animation.
<Style TargetType="{x:Type Button}">
<Style.Triggers>
<EventTrigger RoutedEvent="Click">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard BeginTime="00:00:00"
RepeatBehavior="Forever"
Storyboard.TargetProperty="(Background).(SolidColorBrush.Color)">
<ColorAnimation From="Black" To="Red" Duration="0:0:5"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Style.Triggers>
</Style>