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. 如果 handoffBehaviorSnapshotAndReplaceclocknull,則會從指定的屬性移除所有動畫 (但不會停止)。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.

適用於