Animatable.ApplyAnimationClock 方法

定義

使用指定的 DependencyProperty,建立指定的 AnimationClock 動畫。Animates the specified DependencyProperty using the specified 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)

AnimationClock 套用至指定的 DependencyPropertyApplies an AnimationClock to the specified DependencyProperty. 如果已建立屬性的動畫,則會使用指定的 HandoffBehaviorIf the property is already animated, the specified HandoffBehavior is used.

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

要製作動畫的屬性。The property to animate.

clock
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.

適用於

產品 Introduced

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
Public Sub ApplyAnimationClock (dp As DependencyProperty, clock As AnimationClock, handoffBehavior As HandoffBehavior)

參數

dp
DependencyProperty

要製作動畫的屬性。The property to animate.

clock
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

一個值,這個值指定新的動畫應該如何與已經影響屬性值的任何目前動畫互動。A value that specifies how the new animation should interact with any current animations already affecting the property value.

實作

範例

下列範例顯示如何使用不同的設定來套用動畫時鐘 HandoffBehaviorThe 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

當您使用將 StoryboardAnimationTimeline 或套用 AnimationClock 至屬性時 Compose HandoffBehaviorClock 先前與該屬性相關聯的任何物件都會繼續使用系統資源; 計時系統不會自動移除這些時鐘。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.

適用於

產品 Introduced