[ACCEPTED]-To set blinking effect on button in XAML-xaml

Accepted answer
Score: 10

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 3 Background: This is not that easy to achieve 2 as the framework is using the background 1 for internal stuff, e.g. the hover animation.

See Blinking button on WPF application

Score: 0

If you want to make the button blink on 2 load instead of click on another button 1 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>

More Related questions