views:

168

answers:

2

There is a similar thread else where, but it focues on gameprogramming which I find a little different to regular gui applications with some 'extra sugar'.

What would be the right approach for driving small gui-animations (like expanding/collapsing panels, glowing buttons etc)?

Would it be best to setup a timer to fire at regular intervals, or would it be better to use the idle-event?

How does WPF drive its animations?

I know there are a lot of opinions on whats best out there, so lets collect them all :-)

UPDATE: Ok. I think this came out a little unclear. I'm not using WPF, and I'm not interested in how you trigger an animation in WPF. What I'm after, is a discussion about why a time is better or worse then using an onidle event to drive the animation. Not start it, drive it.

A: 

Maybe I'm getting it wrong but why do you need timer/idle-event if WPF supports animations natively? You may want to take a look at the Animation Overview article at MSDN: http://msdn.microsoft.com/en-us/library/ms752312.aspx

arconaut
+1  A: 

How you drive your animation should be based on your processing priorities.

If you use a timer, you will get called more consistently. This can put you in competition with more important processes for processing power. Driving by OnIdle allows other processes to take charge, but it also means that the animation could get starved.

The correct choice depends your specific priorities.

I'm not sure how WPF handles this, but it would be important to base the animation on the absolute start time rather than incrementing the animation on each call because the animation may not get called at regular intervals.

Josh G