Skip to content

Latest commit

 

History

History
40 lines (28 loc) · 2.75 KB

how-to-animate-a-property-by-using-an-animationclock.md

File metadata and controls

40 lines (28 loc) · 2.75 KB
title description ms.date dev_langs helpviewer_keywords ms.assetid
How to: Animate a Property by Using an AnimationClock
Learn about how to animate a property by using an AnimationClock with several provided code examples.
03/30/2017
csharp
vb
animation [WPF], properties [WPF], with AnimationClocks
AnimationClocks [WPF]
e6542021-714c-4675-9567-04f1c7380834

How to: Animate a Property by Using an AnimationClock

This example shows how to use xref:System.Windows.Media.Animation.Clock objects to animate a property.

There are three ways to animate a dependency property:

  • Create an xref:System.Windows.Media.Animation.AnimationTimeline and associate it with that property by using a xref:System.Windows.Media.Animation.Storyboard.

  • Use the object's xref:System.Windows.Media.Animation.Animatable.BeginAnimation%2A method to apply a single xref:System.Windows.Media.Animation.AnimationTimeline to a target property.

  • Create an xref:System.Windows.Media.Animation.AnimationClock from an xref:System.Windows.Media.Animation.AnimationTimeline and apply it to a property.

xref:System.Windows.Media.Animation.Storyboard objects and the xref:System.Windows.Media.Animation.Animatable.BeginAnimation%2A method enable you to animate properties without directly creating and distributing clocks (for examples, see Animate a Property by Using a Storyboard and Animate a Property Without Using a Storyboard); clocks are created and distributed for you automatically.

Example

The following example shows how to create an xref:System.Windows.Media.Animation.AnimationClock and apply it to two similar properties.

[!code-csharptimingbehaviors_procedural_snip#GraphicsMMCreateAnimationClockWholeClass] [!code-vbtimingbehaviors_procedural_snip#GraphicsMMCreateAnimationClockWholeClass]

For an example showing how to interactively control a xref:System.Windows.Media.Animation.Clock after it starts, see Interactively Control a Clock.

See also