我有以下代码来启动它位于我的Resources
中的动画:
Storyboard _wheelAnimation = FindResource("CircleRotation") as Storyboard;
if (_wheelAnimation == null) return;
_wheelAnimation.Begin(this);
这是我的动画:
<Storyboard x:Key="CircleRotation" RepeatBehavior="Forever">
<DoubleAnimation
Storyboard.TargetName="BigWheelImage"
Storyboard.TargetProperty="RenderTransform.Angle"
From="360" To="0" Duration="0:0:35" BeginTime="00:00:00.000" />
<DoubleAnimation
Storyboard.TargetName="SmallWheelImage"
Storyboard.TargetProperty="RenderTransform.Angle"
From="0" To="360" Duration="0:0:25" BeginTime="00:00:00.000" />
</Storyboard>
我想以编程方式停止它,我尝试了这个:
_wheelAnimation.Stop(); // and also _wheelAnimation.Stop(this);
没有运气...知道为什么它不停止吗?
使用 Begin
时,将第二个参数 (IsControllable
) 设置为 true 以使 Stop
方法工作:
_wheelAnimation.Begin(this, true);
_wheelAnimation.Stop(this);
尝试_wheelAnimation.SkipToFill();