这里有一个简单的矩形旋转动画示例:WPF Rotate rectangle animation in XAML
但是,我只想在鼠标悬停时旋转矩形,并在鼠标移出时停止。到目前为止,这是我的 xaml:
<Button Command="{Binding SettingsCommand}" Style="{DynamicResource SettingButton}">
<Rectangle Width="15" Height="15" RenderTransformOrigin="0.5, 0.5">
<Rectangle.RenderTransform>
<RotateTransform/>
</Rectangle.RenderTransform>
<Rectangle.Triggers>
<EventTrigger RoutedEvent="Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation Storyboard.TargetProperty="(Rectangle.RenderTransform).(RotateTransform.Angle)" To="-360" Duration="0:0:1" RepeatBehavior="Forever"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Rectangle.Triggers>
<Rectangle.Fill>
<VisualBrush Stretch="Fill" Visual="{StaticResource appbar_cog}"/>
</Rectangle.Fill>
</Rectangle>
</Button>
我怎样才能修改它只在鼠标悬停时工作?
谢谢!