[UWP] [VB] [XAML]获取当前正在运行或现有的动画 [英] [UWP][VB][XAML]Get Currently Running Or Existing Animations

查看:91
本文介绍了[UWP] [VB] [XAML]获取当前正在运行或现有的动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个方法可以向Popup添加动画(具体为DoubleAnimation)。 Popup是传递给方法的参数。但是,在添加这些动画之前,我想停下来&删除任何以前添加的动画。动画创建
&首先将动画添加到Storyboard,然后调用Storyboard的Begin()方法,但动画和动画都是如此。故事板是该方法的本地。以下是该方法的重要说明:

< Extension()> Public Sub SlideOpenHorizo​​ntal(pop as Popup)
Dim board As New Storyboard()
'Add DoubleAnimation(s)to board
board.Begin()
End Sub




我想要做的是添加一个语句(作为方法中的第一个语句),它检测并删除以前添加到pop参数的任何动画。有什么方法可以做到这一点吗?谢谢。



Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

解决方案

< blockquote>

嗨Nathan Sokalski,


您似乎想知道动画的当前状态,并试图从故事板中删除
。我的建议是你需要将Storyboard对象缓存在内存中。并使用
Storyboard.GetCurrentState()
方法检查当前状态故事板。此属性表示故事板是否为动画。然后你可以通过
获得动画集
Storyboard.Children
propery。此属性返回包含所有TimeLine对象的TimelineCollection对象。然后你可以从Collection中删除所有动画。


以下是一些示例代码:



 //获取故事板的当前状态
Dim d As ClockState = Mystoryboard.GetCurrentState ()
//获取动画集合
Dim collection As TimelineCollection = Mystoryboard.Children





最好的问候,


罗伊


I have a method which adds animations (DoubleAnimation to be specific) to a Popup. The Popup is a parameter passed to the method. However, before adding these animations I want to stop & remove any previously added animations. The animations are created & started by adding the animations to a Storyboard and then calling the Begin() method of the Storyboard, but both the animations & Storyboard are local to the method. Here are the significant statements of the method:

<Extension()> Public Sub SlideOpenHorizontal(pop As Popup)
	Dim board As New Storyboard()
	'Add DoubleAnimation(s) to board
	board.Begin()
End Sub


What I want to do is add a statement (as the first statement in the method) that detects and removes any animations previously added to the pop parameter. Is there any way I can do this? Thanks.


Nathan Sokalski njsokalski@hotmail.com http://www.nathansokalski.com/

解决方案

Hi Nathan Sokalski,

It seems you want to know the current status of the animation and tried to remove them from the storyboard. My suggestion is that you need to cache the Storyboard object in the memory. And use Storyboard.GetCurrentState() method check the current status of the storyboard. This property represents if the storyboard is animating or not. Then you could get the animation collection by Storyboard.Children propery. This property returns a TimelineCollection object that contains all the TimeLine objects. Then you could remove all the animation from the Collection.

Here is some sample code that you could refer:

      //get current status of the storyboard
      Dim d As ClockState = Mystoryboard.GetCurrentState()
      //get animation collection 
      Dim collection As TimelineCollection = Mystoryboard.Children


Best regards,

Roy


这篇关于[UWP] [VB] [XAML]获取当前正在运行或现有的动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆