Charles Petzold



Animating Points and PointCollections in Silverlight

January 5, 2009
New York, N.Y.

In an ancient blog entry I presented a XAML file that had 13 PointAnimation objects running in parallel to animate a square into a circle and back again.

The animations in that XAML file target the various properties of BezierSegment objects, and it converted very smoothly into Silverlight. Here's the SquaringTheCircle.zip source code (everything I did is in Page.xaml) and you can see it action here:

SquaringTheCircle.html

But I've also been wondering about the feasibility of doing more interesting vector animations in Silverlight. For example, almost two years ago I wrote an article for MSDN Magazine about extending the WPF animation classes to include interpolations between entire PointCollection objects. One example was a templated CheckBox that morphed between a vector "yes" and "no" when it was toggled.

I know that it's not possible to extend the Silverlight animation classes, but perhaps there are workarounds. Here's a feasibility study of a Silverlight text morph:

YesNoYesNoEtc.html

Later this week I'm going to try to clean this up, make it more generalized, use Silverlight animation rather than the CompositionTarget.Rendering event, and get to a point where I can put it into a CheckBox template, but you can see it basically works. Here's the source code. Everything I did is in Page.xaml and Page.xaml.cs.

Of course, once I start messing around with Silverlight PointCollection objects in code, it's going to be hard to know when to stop.