Manual Animations

Of course, even with all the fancy animation support discussed in this chapter, nothing prevents you from animating the old-fashioned way. The classic way to implement animations such as the ones in this chapter is to set up a timer and a callback function that is periodically called based on the frequency of the timer. Inside the callback function, you can manually update the target property (doing a little math to determine the current value based on the elapsed time) until it reaches the final value. At that point, you can stop the timer and/or remove the event handler.

Thanks to the retained-mode graphics model, this approach doesn’t take much work. All the XAML-based frameworks even have their own DispatcherTimer class ...

Get XAML Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.