Ask Learn
Preview
Please sign in to use this experience.
Sign inThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
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.
Applies an animation to a specified dependency property on this element.
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. |
This method is sealed and cannot be overridden.
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)
The identifier for the property to animate.
The animation clock that controls and declares the animation.
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)
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.
Product | Versions |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
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)
The property to animate.
The animation clock that controls and declares the animation.
A value of the enumeration. The default is SnapshotAndReplace, which will stop any existing animation and replace with the new one.
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.
Product | Versions |
---|---|
.NET Framework | 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Please sign in to use this experience.
Sign in