Developer Network Home - Help

Silverlight Animation Basics - Yahoo! Developer Network

Overview

Animations are simply the visual result of changing property values on objects over a period of time. To move something on the screen you might change the Left and Top properties, to make something fade in or out you change the object's Opacity, and so on.

While it's possible to create animations manually in code, it is usually better to utilize the optimized animation capabilities of Silverlight.

Animation Types

Animation Classes

Here are the main classes you will come across when working with animations.

You must use the correct type of animation depending on the data type of the property you are animating.

If the property data type is...

For key-frame animations you'll use the UsingKeyFrames variant, such as DoubleAnimationUsingKeyFrames with a collection of key-frames that use the desired interpolation method.

Triggers

Animations can be started automatically based on Triggers. The following shows starting an animation using the Canvas.Loaded event and the <BeginStoryboard> action. Silverlight 1.0 only supports starting an animation on the Loaded event for an object.

View Sample

Interactive Animations

Animations can also be controlled interactively from code using the Begin(), Pause(), Resume(), Stop() and Seek() methods. In XAML, use the x:Name attribute to specify an ID for the storyboard you wish to control.

In Silverlight 1.0 you could use the following mouse event handler to start the animation.

Further reading

Related information on the web is listed below.

Copyright © 2008 Yahoo! Inc. All rights reserved.

Privacy Policy - Terms of Service - Copyright Policy - Job Openings