16.5. Storyboards in Code

In the previous chapter, you saw how to create simple one-off animations in code and how to build more sophisticated storyboards—complete with multiple animations and playback controls—with XAML markup. But sometimes, it makes sense to take the more sophisticated storyboard route but do all the hard work in code. In fact, this scenario is fairly common. It occurs any time you have multiple animations to deal with and you don't know in advance how many animations there will be or how they should be configured. (This is the case with the simple bomb-dropping game you'll see in this section.) It also occurs if you want to use the same animation in different windows or you simply want the flexibility to separate all the ...

Get Pro WPF in C# 2010: Windows Presentation Foundation in .NET 4 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.