从.net代码停止和重新启动故事板的正确方法是什么?
我尝试着 ...
myStory.Stop(this);
Run Code Online (Sandbox Code Playgroud)
期待随后调用.Begin(this); 将从零时间线重新启动,但相反,故事板会在停止的地方找到它.
我试过了
.Remove(this);
Run Code Online (Sandbox Code Playgroud)
我试过
.Seek(TimeSpan.Zero);
Run Code Online (Sandbox Code Playgroud)
这也没用.
更多细节......这是我的故事板样本.
<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>
Run Code Online (Sandbox Code Playgroud)
因此,textone中的文本会运行,如果您关闭屏幕并快速返回到屏幕,则texttwo实际上会播放新启动的故事板.因此原始(从第一个屏幕)故事板仍然在播放,即使我已删除,并停止它.
怎么样使用Storyboard.Seek(TimeSpan.Zero)?与在Stream中搜索类似,这应该会让您回到动画的开头.
我评论说您还应该确保IsControllable属性设置为true.记在脑子里!
归档时间: |
|
查看次数: |
11215 次 |
最近记录: |