我有一个动画 但我无法阻止它 因为故事板重复行为属性是“永远” 如何从代码后面停止动画?
这是我的XAML:
<UserControl.Resources>
<Storyboard x:Name="loadingAnimation" x:Key="LoadingAnimation" RepeatBehavior="Forever" SpeedRatio="1" AutoReverse="True">
<DoubleAnimationUsingKeyFrames x:Name="doubleAnimationUsingKeyFrames" Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="pathListBox">
<EasingDoubleKeyFrame KeyTime="0" Value="0"/>
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="ellipse">
<EasingDoubleKeyFrame KeyTime="0:0:1" Value="293.73">
<EasingDoubleKeyFrame.EasingFunction>
<BackEase EasingMode="EaseOut"/>
</EasingDoubleKeyFrame.EasingFunction>
</EasingDoubleKeyFrame>
<EasingDoubleKeyFrame KeyTime="0:0:2" Value="560.097"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</UserControl.Resources>
答案 0 :(得分:0)
以下是您可以做的事情:
Storyboard storyboard = (Storyboard)Resources["LoadingAnimation"];
storyboard.Stop();