【发布时间】:2010-10-24 08:44:53
【问题描述】:
从 .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>
所以 textone 中的文本会运行,如果你关闭屏幕并快速返回屏幕,texttwo 实际上会在新启动的故事板上播放。因此,即使我已将其移除并停止,原始(来自第一个屏幕)故事板仍然存在并正在播放。
【问题讨论】:
-
也许这是我的设置。这是更多信息。我有一个带有 storyOverlay 故事板属性的基类。在子类的 ctor 中,我将 storyOverlay = TryFindResource("storyId") as Storyboard;然后,我正在检查 storyOVerlay != null; { storyOverlay.Remove(this); } 这有什么改变吗?
标签: wpf storyboard