Creating property-based animations
Property-based animations are used to change a dependency property from one value to another in a duration specified. There exists various animation classes under the namespace System.Windows.Media.Animation
, which includes DoubleAnimation
, ColorAnimation
, and PointAnimation
. These are used to create animation based on the type of property being animated.
In this recipe, we will learn how to create property-based animations. Keep in mind that only Dependency Properties can be modifiable during an animation.
Getting ready
To get started with this recipe, let's first create a project. Open Visual Studio IDE and create a project named CH08.PropertyBasedAnimationDemo
, based on the WPF application template.
How to do it...
In this demonstration, we will add a square box to the application window. On mouse hover, we will run a storyboard to change the size and color of the box and then reset it to the initial value on mouse leave. Follow these steps:
- From
Solution...