Friday, May 02, 2008 7:04 PM
Tim Rule
Spline Based Animation Helper
This code sample demonstrates an animation helper class to wrap up the code needed to animate a FrameworkElement's properties. This will work if the property is a double as well all of the object's transform properties. User defined dependency properties do not appear to be animatable in this beta 1 release via the Animation class.
Below is the sample usage of the animation helper methods for a double animation and a transform animation. The implementation of the AnimateTransform method is more complex than AnimateDouble because in order to animate a transform value a default transform needs to present which requires more pre-animation work.
One overload of the methods has a parameter for an animation complete EventHandler. This is useful for simple sequencing of animations.
I'm calling this spline based because the easing is adjusted by changing the animation spline control points. An alternative would be to use key frame animation which passes the start value, end value, and current time into an easing function at every keyframe. CodePlex has a good example of such approach for Silverlight.
![spline[5]](http://blogs.msdn.com/blogfiles/timrule/WindowsLiveWriter/SplineBasedAnimationHelper_8A3A/spline%5B5%5D_1.png)
These methods get things moving around the screen but would need a lot more functionality to be useful in an application.