If you do not set an explicit goal, the goal should be the element to which the animation applies. I would define a style with a trigger / animation on it and apply the style to those specific buttons that you want to show. For instance:
<Style x:Key="MyButtonStyle" TargetType="{x:Type Button}"> <Style.Resources> <Storyboard x:Key="OnMouseEnterStoryboard"> <DoubleAnimation BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)" To="180" /> </Storyboard> <Storyboard x:Key="OnMouseLeaveStoryboard"> <DoubleAnimation BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.RenderTransform).(RotateTransform.Angle)" To="0" /> </Storyboard> </Style.Resources> <Style.Triggers> <EventTrigger RoutedEvent="Mouse.MouseLeave"> <RemoveStoryboard BeginStoryboardName="OnMouseEnterStoryboard_BeginStoryboard"/> <BeginStoryboard x:Name="OnMouseLeaveStoryboard_BeginStoryboard" Storyboard="{StaticResource OnMouseLeaveStoryboard}"/> </EventTrigger> <EventTrigger RoutedEvent="Mouse.MouseEnter"> <BeginStoryboard x:Name="OnMouseEnterStoryboard_BeginStoryboard" Storyboard="{StaticResource OnMouseEnterStoryboard}"/> <RemoveStoryboard BeginStoryboardName="OnMouseLeaveStoryboard_BeginStoryboard"/> </EventTrigger> </Style.Triggers> <Setter Property="RenderTransformOrigin" Value="0.5,0.5"/> <Setter Property="RenderTransform"> <Setter.Value> <RotateTransform/> </Setter.Value> </Setter> </Style>
And then on each button you want to behave as follows:
<Button Style="{StaticResource MyButtonStyle}" ... />
source share