my requirement is I want to set blink effect on button2 when button1 is clicked. I did refer this example for blinking effect on textblock.
but its not working for my button2. I can show you xaml code if you want. plz help me out. Thanks.
my requirement is I want to set blink effect on button2 when button1 is clicked. I did refer this example for blinking effect on textblock.
but its not working for my button2. I can show you xaml code if you want. plz help me out. Thanks.
Try this:
<Button Name="button1" Margin="10" Content="Animate Button2!">
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Click">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard BeginTime="00:00:00"
RepeatBehavior="Forever"
Storyboard.TargetName="button2"
Storyboard.TargetProperty="(Foreground).(SolidColorBrush.Color)">
<ColorAnimation From="Black" To="Red" Duration="0:0:1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Button.Triggers>
</Button>
<Button Name="button2" Margin="10" Content="I will get animated!"></Button>
In case you want to animate the Background: This is not that easy to achieve as the framework is using the background for internal stuff, e.g. the hover animation.
If you want to make the button blink on load instead of click on another button then give it a try to this code.
<Button Name="btnAlert" Background="DarkRed" Content="Amimation is working!" Foreground="White" FontSize="17">
<Button.Triggers>
<EventTrigger RoutedEvent="Button.Loaded">
<EventTrigger.Actions>
<BeginStoryboard>
<Storyboard BeginTime="00:00:00" RepeatBehavior="Forever" Storyboard.TargetName="btnNewVersionAlert" Storyboard.TargetProperty="(Foreground).SolidColorBrush.Color)">
<ColorAnimation From="Black" To="White" Duration="0:0:1"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger.Actions>
</EventTrigger>
</Button.Triggers></Button>