Share via


UIElement.ApplyAnimationClock Metode

Definisi

Menerapkan animasi ke properti dependensi tertentu pada elemen ini.

Overload

ApplyAnimationClock(DependencyProperty, AnimationClock)

Menerapkan animasi ke properti dependensi tertentu pada elemen ini. Animasi yang ada dihentikan dan diganti dengan animasi baru.

ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior)

Menerapkan animasi ke properti dependensi tertentu pada elemen ini, dengan kemampuan untuk menentukan apa yang terjadi jika properti sudah memiliki animasi yang sedang berjalan.

Keterangan

Metode ini disegel dan tidak dapat ditimpa.

ApplyAnimationClock(DependencyProperty, AnimationClock)

Menerapkan animasi ke properti dependensi tertentu pada elemen ini. Animasi yang ada dihentikan dan diganti dengan animasi baru.

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)

Parameter

dp
DependencyProperty

Pengidentifikasi untuk properti untuk menganimasikan.

clock
AnimationClock

Jam animasi yang mengontrol dan mendeklarasikan animasi.

Penerapan

Contoh

Dalam contoh berikut, memiliki RectanglemyAnimatedRectangle animasi waktu tertentu yang diterapkan padanya dengan memanggil 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)

Keterangan

Untuk menghapus animasi dari properti, tentukan pengidentifikasi untuk properti tersebut sebagai dp dan tentukan clock sebagai null. Ini menghapus animasi dan properti animasi diatur ke nilai dasarnya. Namun, jam animasi yang awalnya terkait tidak dihentikan. Animasi lain yang ditetapkan ke jam tersebut akan terus berjalan.

Berlaku untuk

ApplyAnimationClock(DependencyProperty, AnimationClock, HandoffBehavior)

Menerapkan animasi ke properti dependensi tertentu pada elemen ini, dengan kemampuan untuk menentukan apa yang terjadi jika properti sudah memiliki animasi yang sedang berjalan.

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)

Parameter

dp
DependencyProperty

Properti untuk dianimasikan.

clock
AnimationClock

Jam animasi yang mengontrol dan mendeklarasikan animasi.

handoffBehavior
HandoffBehavior

Nilai enumerasi. Defaultnya adalah SnapshotAndReplace, yang akan menghentikan animasi yang ada dan mengganti dengan yang baru.

Penerapan

Keterangan

Untuk menghapus animasi dari properti, tentukan pengidentifikasi untuk properti tersebut sebagai dp dan tentukan clock sebagai null. Ini menghapus animasi dan properti animasi diatur ke nilai dasarnya. Namun, jam animasi yang awalnya terkait tidak dihentikan. Animasi lain yang ditetapkan ke jam tersebut akan terus berjalan.

Berlaku untuk