O'Reilly logo

Pro WPF in C# 2008: Windows Presentation Foundation with .NET 3.5, Second Edition by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Understanding WPF Animation

In previous Windows-based platforms (such as Windows Forms and MFC), developers had to build their own animation systems from scratch. The most common technique was to use a timer in conjunction with some custom painting logic. WPF changes the game with a new property-based animation system. The following two sections describe the difference.

Timer-Based Animation

Imagine you need to make a piece of text spin in the About box of a Windows Forms application. Here's the traditional way you would structure your solution:

  1. Create a timer that fires periodically (say, every 50 milliseconds).

  2. When the timer fires, use an event handler to calculate some animation-related details, such as the new degree of rotation. Then, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required