UIElement.ApplyAnimationClock UIElement.ApplyAnimationClock UIElement.ApplyAnimationClock UIElement.ApplyAnimationClock Method

定义

将动画应用到此元素的指定依赖属性。Applies an animation to a specified dependency property on this element.

重载

ApplyAnimationClock(DependencyProperty, AnimationClock) ApplyAnimationClock(DependencyProperty, AnimationClock) ApplyAnimationClock(DependencyProperty, AnimationClock) 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) ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior) 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.

ApplyAnimationClock(DependencyProperty, AnimationClock) ApplyAnimationClock(DependencyProperty, AnimationClock) ApplyAnimationClock(DependencyProperty, AnimationClock) 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)

参数

dp
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

要进行动画处理的属性的标识符。The identifier for the property to animate.

clock
AnimationClock AnimationClock AnimationClock AnimationClock

控制和声明动画的动画时钟。The animation clock that controls and declares the animation.

实现

示例

在下面的示例中, Rectangle通过调用ApplyAnimationClock , 有一个特定的myAnimatedRectangle计时动画应用于它。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)

注解

若要从属性中删除动画, 请将该属性的标识符指定dp为, clocknull将指定为。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.

ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior) ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior) 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

参数

dp
DependencyProperty DependencyProperty DependencyProperty DependencyProperty

要进行动画处理的属性。The property to animate.

clock
AnimationClock AnimationClock AnimationClock AnimationClock

控制和声明动画的动画时钟。The animation clock that controls and declares the animation.

handoffBehavior
HandoffBehavior HandoffBehavior HandoffBehavior HandoffBehavior

枚举的一个值。A value of the enumeration. 默认值为 SnapshotAndReplace,这会停止任何现有动画并将其替换为新动画。The default is SnapshotAndReplace, which will stop any existing animation and replace with the new one.

实现

注解

若要从属性中删除动画, 请将该属性的标识符指定dp为, clocknull将指定为。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.

适用于