如何在 .net 代码中正确停止和重新启动一个故事板?
我正在尝试...
myStory.Stop(this);
期望下一次调用 .Begin(this); 会从时间轴的零开始重新启动,但实际上故事板从停止的地方继续运行。
我已经尝试过
.Remove(this);
我尝试过
.Seek(TimeSpan.Zero);
这也没有起作用。
更多细节...这是我的故事板示例。
<Storyboard x:Key="overlay">
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="textone" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:03.0" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:03.0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:06.0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:06.0" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="texttwo" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:07.0" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:07.0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:10.0" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:10.0" Value="0"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
因此,当您关闭屏幕并迅速返回屏幕时,文本one中的文本会继续运行,并且文本two实际上会在一个新启动的故事板上播放。 因此,即使我已将其删除并停止播放,但最初(来自第一屏幕)的故事板仍然存在并正在播放。