Animatable.ApplyAnimationClock Animatable.ApplyAnimationClock Animatable.ApplyAnimationClock Animatable.ApplyAnimationClock Method

定义

使用指定的 DependencyProperty 对指定的 AnimationClock 进行动画处理。Animates the specified DependencyProperty using the specified AnimationClock.

重载

ApplyAnimationClock(DependencyProperty, AnimationClock) ApplyAnimationClock(DependencyProperty, AnimationClock) ApplyAnimationClock(DependencyProperty, AnimationClock) ApplyAnimationClock(DependencyProperty, AnimationClock)

AnimationClock 应用到指定的 DependencyPropertyApplies an AnimationClock to the specified DependencyProperty. 如果该属性已进行动画处理,则使用 SnapshotAndReplace 切换行为。If the property is already animated, the SnapshotAndReplace handoff behavior is used.

ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior) ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior) ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior)

AnimationClock 应用到指定的 DependencyPropertyApplies an AnimationClock to the specified DependencyProperty. 如果该属性已进行动画处理,则使用指定的 HandoffBehaviorIf the property is already animated, the specified HandoffBehavior is used.

ApplyAnimationClock(DependencyProperty, AnimationClock) ApplyAnimationClock(DependencyProperty, AnimationClock) ApplyAnimationClock(DependencyProperty, AnimationClock) ApplyAnimationClock(DependencyProperty, AnimationClock)

AnimationClock 应用到指定的 DependencyPropertyApplies an AnimationClock to the specified DependencyProperty. 如果该属性已进行动画处理,则使用 SnapshotAndReplace 切换行为。If the property is already animated, the SnapshotAndReplace handoff behavior is used.

public:
 virtual void ApplyAnimationClock(System::Windows::DependencyProperty ^ dp, System::Windows::Media::Animation::AnimationClock ^ clock);
public void ApplyAnimationClock (System.Windows.DependencyProperty dp, System.Windows.Media.Animation.AnimationClock clock);
abstract member ApplyAnimationClock : System.Windows.DependencyProperty * System.Windows.Media.Animation.AnimationClock -> unit
override this.ApplyAnimationClock : System.Windows.DependencyProperty * System.Windows.Media.Animation.AnimationClock -> unit
Public Sub ApplyAnimationClock (dp As DependencyProperty, clock As AnimationClock)

参数

dp
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

要进行动画处理的属性。The property to animate.

clock
AnimationClock AnimationClock AnimationClock AnimationClock

用于动画处理指定属性的时钟。The clock with which to animate the specified property. 如果 clocknull,则将从指定属性删除(而非停止)所有动画。If clock is null, all animations will be removed from the specified property (but not stopped).

实现

注解

请注意, 使用此方法从属性中删除时钟不会停止这些时钟。Note that using this method to removing clocks from a property does not stop those clocks.

ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior) ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior) ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior)

AnimationClock 应用到指定的 DependencyPropertyApplies an AnimationClock to the specified DependencyProperty. 如果该属性已进行动画处理,则使用指定的 HandoffBehaviorIf the property is already animated, the specified HandoffBehavior is used.

public:
 virtual void ApplyAnimationClock(System::Windows::DependencyProperty ^ dp, System::Windows::Media::Animation::AnimationClock ^ clock, System::Windows::Media::Animation::HandoffBehavior handoffBehavior);
public void ApplyAnimationClock (System.Windows.DependencyProperty dp, System.Windows.Media.Animation.AnimationClock clock, System.Windows.Media.Animation.HandoffBehavior handoffBehavior);
abstract member ApplyAnimationClock : System.Windows.DependencyProperty * System.Windows.Media.Animation.AnimationClock * System.Windows.Media.Animation.HandoffBehavior -> unit
override this.ApplyAnimationClock : System.Windows.DependencyProperty * System.Windows.Media.Animation.AnimationClock * System.Windows.Media.Animation.HandoffBehavior -> unit

参数

dp
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

要进行动画处理的属性。The property to animate.

clock
AnimationClock AnimationClock AnimationClock AnimationClock

用于动画处理指定属性的时钟。The clock with which to animate the specified property. 如果 handoffBehaviorSnapshotAndReplace 并且 clocknull,则将从指定的属性中移除(但不停止)所有动画。If handoffBehavior is SnapshotAndReplace and clock is null, all animations will be removed from the specified property (but not stopped). 如果 handoffBehaviorCompose 并且时钟为 null,则此方法不起作用。If handoffBehavior is Compose and clock is null, this method has no effect.

handoffBehavior
HandoffBehavior HandoffBehavior HandoffBehavior HandoffBehavior

一个值,用来指定新动画应该如何与当前已在影响该属性值的任何动画进行交互。A value that specifies how the new animation should interact with any current animations already affecting the property value.

实现

示例

下面的示例演示如何使用不同HandoffBehavior的设置应用动画时钟。The following example shows how to apply animation clocks using different HandoffBehavior settings.

注解

请注意, 使用此方法从属性中删除时钟不会停止这些时钟。Note that using this method to remove clocks from a property does not stop those clocks.

使用撰写 HandoffBehaviorUsing the Compose HandoffBehavior

Storyboard AnimationTimeline使用将、AnimationClock或应用到属性时Clock , 以前与该属性关联的任何对象将继续使用系统资源; 计时系统不会HandoffBehavior Compose自动删除这些时钟。When you apply a Storyboard, AnimationTimeline, or AnimationClock to a property using the Compose HandoffBehavior, any Clock objects previously associated with that property continue to consume system resources; the timing system will not remove these clocks automatically.

若要避免在使用Compose应用大量时钟时出现性能问题, 应在完成后从动画属性中删除组合时钟。To avoid performance issues when you apply a large number of clocks using Compose, you should remove composing clocks from the animated property after they complete. 删除时钟有多种方法。There are several ways to remove a clock.

此动画问题主要出现在生存期较长的对象上。This is primarily an issue for animations on objects that have a long lifetime. 当对某个对象进行垃圾回收时,它的时钟也会断开连接并进行垃圾回收。When an object is garbage collected, its clocks will also be disconnected and garbage collected.

有关时钟对象的详细信息, 请参阅动画和计时系统概述For more information about clock objects, see the Animation and Timing System Overview.

适用于