Animatable.ApplyAnimationClock Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Animates the specified DependencyProperty using the specified AnimationClock.
Overloads
ApplyAnimationClock(DependencyProperty, AnimationClock) |
Applies an AnimationClock to the specified DependencyProperty. If the property is already animated, the SnapshotAndReplace handoff behavior is used. |
ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior) |
Applies an AnimationClock to the specified DependencyProperty. If the property is already animated, the specified HandoffBehavior is used. |
ApplyAnimationClock(DependencyProperty, AnimationClock)
Applies an AnimationClock to the specified DependencyProperty. 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)
Parameters
The property to animate.
- clock
- AnimationClock
The clock with which to animate the specified property. If clock
is null
, all animations will be removed from the specified property (but not stopped).
Implements
Remarks
Note that using this method to removing clocks from a property does not stop those clocks.
Applies to
ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior)
Applies an AnimationClock to the specified DependencyProperty. If 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)
Parameters
The property to animate.
- clock
- AnimationClock
The clock with which to animate the specified property. If handoffBehavior
is SnapshotAndReplace and clock
is null
, all animations will be removed from the specified property (but not stopped). 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.
Implements
Examples
The following example shows how to apply animation clocks using different HandoffBehavior settings.
Remarks
Note that using this method to remove clocks from a property does not stop those clocks.
Using the Compose HandoffBehavior
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.
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.
To remove all clocks from a property, use the ApplyAnimationClock(DependencyProperty, AnimationClock) or BeginAnimation(DependencyProperty, AnimationTimeline) method of the animated object. Specify the property being animated as the first parameter, and
null
as the second. This will remove all animation clocks from the property.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. This is typically done in the Completed event handler for a clock. Note that only root clocks can be controlled by a ClockController; the Controller property of a child clock will return
null
. Note also that the Completed event will not be called if the effective duration of the clock is forever. In that case, the user will need to 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 will also be disconnected and garbage collected.
For more information about clock objects, see the Animation and Timing System Overview.