Encapsulating Animations

When you create animations dynamically in code, a fair bit of boilerplate code is required to create the animations, set the storyboard properties, and handle the Completed event to clean up. For this reason, Silverlight developers often wrap animations in higher-level classes that take care of the low-level details.

For example, you can create an animation class named FadeElementEffect and fade an element out of view using code like this:

Dim fade As New FadeElementEffect() fade.Animate(canvas)

Creating classes like this is fairly straightforward, although the exact design depends on the needs of your application. In the rest of this section, you'll consider one possible way to create animation helper classes that ...

Get Pro Silverlight 5 in VB 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.