Animation
In an earlier article in the WPF tutorial we briefly saw animation and how it can be used with triggers. Animation in WPF varies from simple, smooth movements, fades and colour changes through to complex animations of multiple properties, controlled by storyboards.
To create and trigger them, it is important to understand the available types of animation. WPF includes dozens of standard animation classes that can modify the values of various data types. It would be impractical and repetitive to describe them all. Instead, we'll categorise the animation classes into four groups. We'll look at three of these categories, with examples of each, over the next few articles in the series.
There are four groups of animation classes. Each uses a different naming convention, making it easy for you to understand how they operate and with which data types they are compatible. They are:
Basic From/To Animations
The simplest form of animation is the type that we've seen in the examples in earlier articles. A target property is changed from one value to another, with intermediate values calculated automatically by WPF. This allows smooth transitions, movements and translations.
Basic animation classes are named according to the data type upon which they operate. The type name is followed by the text, "Animation". The types include:
- ByteAnimation
- CharAnimation
- ColorAnimation
- DecimalAnimation
- DoubleAnimation
- Int16Animation
- Int32Animation
- Int64Animation
- MatrixAnimation
- Point3DAnimation
- PointAnimation
- QuaternionAnimation
- RectAnimation
- RotationAnimation
- SingleAnimation
- SizeAnimation
- ThicknessAnimation
- Vector3DAnimation
- VectorAnimation
Key-Frame Animations
Key-frame animations allow you to specify more than two target values. In addition to the start and end values of a basic animation, you provide intermediate values and timings. WPF automatically interpolates to create smooth transitions between all of the values in turn.
All of the key-frame animations are named according to the data type they affect, followed by the text, "AnimationUsingKeyframes". The available animations include:
- BooleanAnimationUsingKeyFrames
- ByteAnimationUsingKeyFrames
- CharAnimationUsingKeyFrames
- ColorAnimationUsingKeyFrames
- DecimalAnimationUsingKeyFrames
- Int16AnimationUsingKeyFrames
- Int32AnimationUsingKeyFrames
- Int64AnimationUsingKeyFrames
- MatrixAnimationUsingKeyFrames
- ObjectAnimationUsingKeyFrames
- Point3DAnimationUsingKeyFrames
- PointAnimationUsingKeyFrames
- QuaternionAnimationUsingKeyFrames
- RectAnimationUsingKeyFrames
- RotationAnimationUsingKeyFrames
- SingleAnimationUsingKeyFrames
- SizeAnimationUsingKeyFrames
- StringAnimationUsingKeyFrames
- ThicknessAnimationUsingKeyFrames
- Vector3DAnimationUsingKeyFrames
- VectorAnimationUsingKeyFrames
28 April 2015