pihole.org

Taking charge of animation in WPF

Posted on: September 30, 2008

While working on OrangeNote, I decided that I wanted a nice modern spinner animation to indicate when a task (like a note search) was being performed asynchronously in the background. You see these things everywhere, and I personally find them pretty slick, but I couldn’t find anything out there already cooked up in WPF, and figured it would be a good learning experience (especially with regards to animation), so I decided to whip up my own.

It didn’t take long before I ran into a pretty solid limitation (or oversight perhaps) concerning animations in WPF: they are all specified with respect to a single property to be animated. In other words, there’s no global, top-down view of the state of objects involved in an animation–everything is fragmented and split up into parallel timelines. Time is innately global. It’s perhaps the most global of all things.

Suffice it to say I found this frustrating and confusing, so my quest to develop a spinning wheel animation quickly escalated into something much more: a new way to do animation in WPF.

I pulled up a copy of WordPad (OrangeNote wasn’t quite usable at this point) and jotted down some rough theoretical ideas for how I might achieve what I wanted. I wanted to keep it simple, and reuse as much of the existing infrastructure as possible, while focusing on enabling multiple properties to be animated together within the confines of a single sequential timeline. I decided the best approach was to think of transforming an ideal representation into an equivalent native representation that WPF could understand. It all has to do with factoring (yes, the same kind of factoring from high-school algebra). The idea is this: take a time-dominant form of representing an animation (where time is on the outside, and property states–represented by Setters–are on the inside) and turn it into the native property-dominant form that WPF is based on.

Turns out it worked. You can read all about it in my latest Code Project article. So if you’re stuck on a particularly complicated animation in WPF and are frustrated that you can’t think globally, check it out. And for that matter, tell your friends too. It’s completely free and open source, of course, and it even includes a spinning wheel demo project. 😉

final1

Advertisements

2 Responses to "Taking charge of animation in WPF"

Logan,

Nice new make over! This WPF thing sure looks snazzy!

WPF is pretty amazing once you get the hang of it. It’s incredibly powerful, but also incredibly difficult to figure out, and there a lot of subtle annoyances that make things difficult, but the benefits outweigh the downsides as far as I’m concerned, and there’s always hope those inconveniences will be gradually eliminated as the platform matures.

There’s also a lot of active development by the community (especially the CPians!) to improve it as well, and of course I hope my work turns out to be helpful to others too.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Adventures in theoretical computer science, with your host, chaiguy1337

What I’m Running

Software tracking

OrangeNote™ Users

Top Clicks

  • None

RSS DotNetKicks

  • An error has occurred; the feed is probably down. Try again later.

Blog Stats

  • 12,264 hits
Advertisements
%d bloggers like this: