我有以下代码来启动它位于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);
没有运气......对于它为什么不停止的任何想法?
答案 0 :(得分:3)
使用Begin
时,将第二个参数(IsControllable
)设置为true,以使Stop
方法有效:
_wheelAnimation.Begin(this, true);
_wheelAnimation.Stop(this);
答案 1 :(得分:-1)
尝试_wheelAnimation.SkipToFill();