Rediger

Del via


UIElement.ApplyAnimationClock Method

Definition

Applies an animation to a specified dependency property on this element.

Overloads

ApplyAnimationClock(DependencyProperty, AnimationClock)

Applies an animation to a specified dependency property on this element. Any existing animations are stopped and replaced with the new animation.

ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior)

Applies an animation to a specified dependency property on this element, with the ability to specify what happens if the property already has a running animation.

Remarks

This method is sealed and cannot be overridden.

ApplyAnimationClock(DependencyProperty, AnimationClock)

Applies an animation to a specified dependency property on this element. Any existing animations are stopped and replaced with the new animation.

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

dp
DependencyProperty

The identifier for the property to animate.

clock
AnimationClock

The animation clock that controls and declares the animation.

Implements

Examples

In the following example, a Rectangle myAnimatedRectangle has a particular timing animation applied to it by calling ApplyAnimationClock .

// Create a DoubleAnimation to
// animate its width.
DoubleAnimation widthAnimation = 
    new DoubleAnimation(
        100,
        500, 
        new Duration(TimeSpan.FromSeconds(5)));
//widthAnimation.RepeatBehavior = RepeatBehavior.Forever;
widthAnimation.AutoReverse = true;
widthAnimation.SpeedRatio = 0.5;
        
// Create a clock from the animation.
myControllableClock = widthAnimation.CreateClock();

// Apply the clock to the rectangle's Width property.
animatedRectangle.ApplyAnimationClock(
    Rectangle.WidthProperty, myControllableClock);
' Create a DoubleAnimation to
' animate its width.
'widthAnimation.RepeatBehavior = RepeatBehavior.Forever
Dim widthAnimation As New DoubleAnimation(100, 500, New Duration(TimeSpan.FromSeconds(5))) With {
    .AutoReverse = True,
    .SpeedRatio = 0.5
}

    ' Create a clock from the animation.
myControllableClock = widthAnimation.CreateClock()

' Apply the clock to the rectangle's Width property.
animatedRectangle.ApplyAnimationClock(Rectangle.WidthProperty, myControllableClock)

Remarks

To remove an animation from a property, specify the identifier for that property as dp and specify clock as null. This removes the animation and the animated property is set to its base value. However, the originally associated animation clock is not stopped. Any other animations assigned to that clock will continue to run.

Applies to

ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior)

Applies an animation to a specified dependency property on this element, with the ability to specify what happens if the property already has a running animation.

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

dp
DependencyProperty

The property to animate.

clock
AnimationClock

The animation clock that controls and declares the animation.

handoffBehavior
HandoffBehavior

A value of the enumeration. The default is SnapshotAndReplace, which will stop any existing animation and replace with the new one.

Implements

Remarks

To remove an animation from a property, specify the identifier for that property as dp and specify clock as null. This removes the animation and the animated property is set to its base value. However, the originally associated animation clock is not stopped. Any other animations assigned to that clock will continue to run.

Applies to