views:

7

answers:

0

Got a bog standard button with a style that sets its margin. I followed a tutorial to add animation to it, but I want to move this into the style so I can apply the same animation to all my buttons.

I've tried a few ways but without any success, could anyone point me in the right direction?

<Button Name="btn7" Grid.Column="2" Grid.Row="2" Style="{StaticResource btnStyle}">
                <Button.Triggers>
                    <EventTrigger RoutedEvent="Button.MouseEnter">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation From="1" To="0.5" Duration="0:0:0.25" RepeatBehavior="1x" AutoReverse="False" Storyboard.TargetName="btn7" Storyboard.TargetProperty="Opacity"></DoubleAnimation>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                    <EventTrigger RoutedEvent="Button.MouseLeave">
                        <BeginStoryboard>
                            <Storyboard>
                                <DoubleAnimation From="0.5" To="1" Duration="0:0:0.25" RepeatBehavior="1x" AutoReverse="False" Storyboard.TargetName="btn7" Storyboard.TargetProperty="Opacity"></DoubleAnimation>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger>
                </Button.Triggers>
            </Button>