FrameworkElement.BeginStoryboard 方法
定义
开始所提供的演示图板中包含的操作序列。Begins the sequence of actions contained in the provided storyboard.
重载
BeginStoryboard(Storyboard) |
开始所提供的演示图板中包含的操作序列。Begins the sequence of actions that are contained in the provided storyboard. |
BeginStoryboard(Storyboard, HandoffBehavior) |
开始所提供的演示图板中包含的操作序列,并指定选项来指明当已对属性进行动画处理时应发生的行为。Begins the sequence of actions contained in the provided storyboard, with options specified for what should happen if the property is already animated. |
BeginStoryboard(Storyboard, HandoffBehavior, Boolean) |
开始所提供的演示图板中包含的操作序列,并使动画控件在动画开始后具有指定的状态。Begins the sequence of actions contained in the provided storyboard, with specified state for control of the animation after it is started. |
BeginStoryboard(Storyboard)
开始所提供的演示图板中包含的操作序列。Begins the sequence of actions that are contained in the provided storyboard.
public:
void BeginStoryboard(System::Windows::Media::Animation::Storyboard ^ storyboard);
public void BeginStoryboard (System.Windows.Media.Animation.Storyboard storyboard);
member this.BeginStoryboard : System.Windows.Media.Animation.Storyboard -> unit
Public Sub BeginStoryboard (storyboard As Storyboard)
参数
- storyboard
- Storyboard
要开始的演示图板。The storyboard to begin.
示例
下面的示例 Storyboard 从资源中检索,然后 Storyboard 在对内部事件进行类处理时运行。The following example retrieves a Storyboard from resources, and then runs that Storyboard when an internal event is class handled.
private void OnImage1Animate(object sender, RoutedEventArgs e)
{
Storyboard s;
s = (Storyboard)this.FindResource("RotateStoryboard");
this.BeginStoryboard(s);
}
Private Sub OnImage1Animate(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim s As Storyboard
s = CType(Me.FindResource("RotateStoryboard"), Storyboard)
Me.BeginStoryboard(s)
End Sub
注解
最典型的动画方案不使用此方法。Most typical animation scenarios do not use this method. 通常,您可以 Storyboard BeginStoryboard 在标记中创建或元素,然后将它们放置为 EventTrigger 元素上的内容。Typically, you create the Storyboard or BeginStoryboard element in markup, and then you place these as the EventTrigger content on an element. 当事件触发时,动画将运行。When triggered by the event, the animation then runs. Storyboard可以通过在标记中公开的属性来处理的大多数控制方面。Most of the control aspects of a Storyboard can be addressed by properties that are exposed in markup.
对于不使用 isControllable
、参数或指定了该参数的签名 false
,一旦动画达到 "填充" 时间段,就会删除与动画关联的时间线时钟。For the signatures that do not use the isControllable
, parameter, or when that parameter is specified false
, the timeline clocks that are associated with the animation are removed as soon as the animation reaches the "Fill" period. 因此,不能在运行后重新启动动画。Therefore the animation cannot be restarted after running once. 控制动画还要求情节提要具有 X:Name 指令 或可通过代码中的引用进行访问。Controlling an animation also requires that the storyboard have an x:Name Directive or be accessible by reference in code.
适用于
BeginStoryboard(Storyboard, HandoffBehavior)
开始所提供的演示图板中包含的操作序列,并指定选项来指明当已对属性进行动画处理时应发生的行为。Begins the sequence of actions contained in the provided storyboard, with options specified for what should happen if the property is already animated.
public:
void BeginStoryboard(System::Windows::Media::Animation::Storyboard ^ storyboard, System::Windows::Media::Animation::HandoffBehavior handoffBehavior);
public void BeginStoryboard (System.Windows.Media.Animation.Storyboard storyboard, System.Windows.Media.Animation.HandoffBehavior handoffBehavior);
member this.BeginStoryboard : System.Windows.Media.Animation.Storyboard * System.Windows.Media.Animation.HandoffBehavior -> unit
Public Sub BeginStoryboard (storyboard As Storyboard, handoffBehavior As HandoffBehavior)
参数
- storyboard
- Storyboard
要开始的演示图板。The storyboard to begin.
- handoffBehavior
- HandoffBehavior
一个枚举值,该值描述演示图板中描述的属性在经过动画处理后要使用的行为。A value of the enumeration that describes behavior to use if a property described in the storyboard is already animated.
示例
下面的示例 Storyboard 从资源中检索,然后 Storyboard 在对内部事件进行类处理时运行。The following example retrieves a Storyboard from resources, and then runs that Storyboard when an internal event is class handled.
private void OnImage1Animate(object sender, RoutedEventArgs e)
{
Storyboard s;
s = (Storyboard)this.FindResource("RotateStoryboard");
this.BeginStoryboard(s);
}
Private Sub OnImage1Animate(ByVal sender As Object, ByVal e As RoutedEventArgs)
Dim s As Storyboard
s = CType(Me.FindResource("RotateStoryboard"), Storyboard)
Me.BeginStoryboard(s)
End Sub
注解
最典型的动画方案不使用此方法。Most typical animation scenarios do not use this method. 通常,您可以 Storyboard BeginStoryboard 在标记中创建或元素,然后将它们放置为 EventTrigger 元素上的内容。Typically, you create the Storyboard or BeginStoryboard element in markup, and then you place these as the EventTrigger content on an element. 当事件触发时,动画将运行。When triggered by the event, the animation then runs. Storyboard可以通过在标记中公开的属性来处理的大多数控制方面。Most of the control aspects of a Storyboard can be addressed by properties that are exposed in markup.
对于不使用 isControllable
、参数或指定了该参数的签名 false
,一旦动画达到 "填充" 时间段,就会删除与动画关联的时间线时钟。For the signatures that do not use the isControllable
, parameter, or when that parameter is specified false
, the timeline clocks that are associated with the animation are removed as soon as the animation reaches the "Fill" period. 因此,不能在运行后重新启动动画。Therefore the animation cannot be restarted after running once. 控制动画还要求情节提要具有 X:Name 指令 或可通过代码中的引用进行访问。Controlling an animation also requires that the storyboard have an x:Name Directive or be accessible by reference in code.
可以将移交行为指定为的属性 BeginStoryboard 。Handoff behavior can be specified as an attribute of BeginStoryboard.
使用撰写 HandoffBehaviorUsing the Compose HandoffBehavior
Storyboard使用将、或应用 AnimationTimeline AnimationClock 到属性时 Compose HandoffBehavior , Clock 以前与该属性关联的任何对象将继续使用系统资源; 计时系统不会自动删除时钟。When you apply a Storyboard, AnimationTimeline, or AnimationClock to a property by using the Compose HandoffBehavior, any Clock objects previously associated with that property continue to consume system resources; the timing system does not remove the clocks automatically.
若要避免在使用应用大量时钟时出现性能问题 Compose ,应在完成后从动画属性中删除组合时钟。To avoid performance issues when you apply a large number of clocks by using Compose, you should remove composing clocks from the animated property after they complete. 有几种方法可以删除时钟:There are several ways to remove a clock:
若要从属性中删除所有时钟,请 ApplyAnimationClock(DependencyProperty, AnimationClock) 使用 BeginAnimation(DependencyProperty, AnimationTimeline) 动画对象的或方法。To remove all clocks from a property, use the ApplyAnimationClock(DependencyProperty, AnimationClock) or BeginAnimation(DependencyProperty, AnimationTimeline) method of the animated object. 将要进行动画处理的属性指定为第一个参数,并将指定
null
为第二个参数。Specify the property being animated as the first parameter, andnull
as the second. 这将从属性中移除所有动画时钟。This removes all animation clocks from the property.若要从时钟列表中删除特定的 AnimationClock ,请使用 Controller 的属性 AnimationClock 来检索 ClockController ,然后调用的 Remove 方法 ClockController 。To remove a specific AnimationClock from a list of clocks, use the Controller property of the AnimationClock to retrieve a ClockController, then call the Remove method of the ClockController. 通常在 Completed 时钟的事件处理程序中完成此操作。This is typically done in the Completed event handler for a clock. 请注意,只能通过控制根时钟, ClockController Controller 子时钟的属性返回
null
。Note that only root clocks can be controlled by a ClockController; the Controller property of a child clock returnsnull
. 另请注意, Completed 如果时钟的有效持续时间是永久性的,则不会引发事件。Note also that the Completed event is not raised if the effective duration of the clock is forever. 在这种情况下,用户必须确定何时调用 Remove 。In that case, the user must determine when to call Remove.
此动画问题主要出现在生存期较长的对象上。This is primarily an issue for animations on objects that have a long lifetime. 当对对象进行垃圾回收时,还会断开其时钟的连接并对其进行垃圾回收。When an object is garbage collected, its clocks are also disconnected and garbage collected.
有关时钟对象的详细信息,请参阅 动画和计时系统概述。For more information about clock objects, see Animation and Timing System Overview.
适用于
BeginStoryboard(Storyboard, HandoffBehavior, Boolean)
开始所提供的演示图板中包含的操作序列,并使动画控件在动画开始后具有指定的状态。Begins the sequence of actions contained in the provided storyboard, with specified state for control of the animation after it is started.
public:
void BeginStoryboard(System::Windows::Media::Animation::Storyboard ^ storyboard, System::Windows::Media::Animation::HandoffBehavior handoffBehavior, bool isControllable);
public void BeginStoryboard (System.Windows.Media.Animation.Storyboard storyboard, System.Windows.Media.Animation.HandoffBehavior handoffBehavior, bool isControllable);
member this.BeginStoryboard : System.Windows.Media.Animation.Storyboard * System.Windows.Media.Animation.HandoffBehavior * bool -> unit
Public Sub BeginStoryboard (storyboard As Storyboard, handoffBehavior As HandoffBehavior, isControllable As Boolean)
参数
- storyboard
- Storyboard
要开始的演示图板。The storyboard to begin.
- handoffBehavior
- HandoffBehavior
一个枚举值,该值描述演示图板中描述的属性在经过动画处理后要使用的行为。A value of the enumeration that describes behavior to use if a property described in the storyboard is already animated.
- isControllable
- Boolean
声明在动画开始后是否仍可以对它进行控制(可以暂停)。Declares whether the animation is controllable (can be paused) after it is started.
注解
最典型的动画方案不使用此方法。Most typical animation scenarios do not use this method. 通常,您可以 Storyboard BeginStoryboard 在标记中创建或元素,然后将它们放置为 EventTrigger 元素上的内容。Typically, you create the Storyboard or BeginStoryboard element in markup, and then you place these as the EventTrigger content on an element. 当事件触发时,动画将运行。When triggered by the event, the animation then runs. Storyboard可以通过在标记中公开的属性来处理的大多数控制方面。Most of the control aspects of a Storyboard can be addressed by properties that are exposed in markup.
对于不使用 isControllable
、参数或指定了该参数的签名 false
,一旦动画达到 "填充" 时间段,就会删除与动画关联的时间线时钟。For the signatures that do not use the isControllable
, parameter, or when that parameter is specified false
, the timeline clocks that are associated with the animation are removed as soon as the animation reaches the "Fill" period. 因此,不能在运行后重新启动动画。Therefore the animation cannot be restarted after running once. 控制动画还要求情节提要具有 X:Name 指令 或可通过代码中的引用进行访问。Controlling an animation also requires that the storyboard have an x:Name Directive or be accessible by reference in code.
可以将移交行为指定为的属性 BeginStoryboard 。Handoff behavior can be specified as an attribute of BeginStoryboard.
使用撰写 HandoffBehaviorUsing the Compose HandoffBehavior
Storyboard使用将、或应用 AnimationTimeline AnimationClock 到属性时 Compose HandoffBehavior , Clock 以前与该属性关联的任何对象将继续使用系统资源; 计时系统不会自动删除时钟。When you apply a Storyboard, AnimationTimeline, or AnimationClock to a property by using the Compose HandoffBehavior, any Clock objects previously associated with that property continue to consume system resources; the timing system does not remove the clocks automatically.
若要避免在使用应用大量时钟时出现性能问题 Compose ,应在完成后从动画属性中删除组合时钟。To avoid performance issues when you apply a large number of clocks by using Compose, you should remove composing clocks from the animated property after they complete. 有几种方法可以删除时钟:There are several ways to remove a clock:
若要从属性中删除所有时钟,请 ApplyAnimationClock(DependencyProperty, AnimationClock) 使用 BeginAnimation(DependencyProperty, AnimationTimeline) 动画对象的或方法。To remove all clocks from a property, use the ApplyAnimationClock(DependencyProperty, AnimationClock) or BeginAnimation(DependencyProperty, AnimationTimeline) method of the animated object. 将要进行动画处理的属性指定为第一个参数,并将指定
null
为第二个参数。Specify the property being animated as the first parameter, andnull
as the second. 这将从属性中移除所有动画时钟。This removes all animation clocks from the property.若要从时钟列表中删除特定的 AnimationClock ,请使用 Controller 的属性 AnimationClock 来检索 ClockController ,然后调用的 Remove 方法 ClockController 。To remove a specific AnimationClock from a list of clocks, use the Controller property of the AnimationClock to retrieve a ClockController, then call the Remove method of the ClockController. 通常在 Completed 时钟的事件处理程序中完成此操作。This is typically done in the Completed event handler for a clock. 请注意,只能通过控制根时钟, ClockController Controller 子时钟的属性返回
null
。Note that only root clocks can be controlled by a ClockController; the Controller property of a child clock returnsnull
. 另请注意, Completed 如果时钟的有效持续时间是永久性的,则不会引发事件。Note also that the Completed event is not raised if the effective duration of the clock is forever. 在这种情况下,用户必须确定何时调用 Remove 。In that case, the user must determine when to call Remove.
此动画问题主要出现在生存期较长的对象上。This is primarily an issue for animations on objects that have a long lifetime. 当对对象进行垃圾回收时,还会断开其时钟的连接并对其进行垃圾回收。When an object is garbage collected, its clocks are also disconnected and garbage collected.
有关时钟对象的详细信息,请参阅 动画和计时系统概述。For more information about clock objects, see Animation and Timing System Overview.