Animation and Storyboard

Before getting closer to Silverlight, I used to make animation and some application by Flash.

Now, I have to remind all the people, who used to design Flash Application before, should be clear that it has a new system in Silverlight which is totally different from Flash.

We have Storyboard to control the animation of different objects but we have Movie Clip to control those in Flash.

In flash we have to create animation by time line everywhere, but we can do all the animation separately in Silverlight.

We create animation in code-behind as follow:

First we create our new Storyboard and Double Animation :

Storyboard Reflection_Story1 = new Storyboard(); 
DoubleAnimation Reflection_fades = new DoubleAnimation();

Then we have to set what the animation do, the value changed from …. to ….

Reflection_fades.From = 0;
Reflection_fades.To = 1;

Furthermore, we have to let the computer know, how long is the animation last for?

Reflection_fades.Duration = new Duration(TimeSpan.Parse("0:0:1"));

After that, what else we left? We have to tell the computer which object we want to apply for this animation.

Storyboard.SetTarget(Reflection_fades, Target_item);

Also, the property that you are changing from 0 to 1 on the Targert_item.

Storyboard.SetTargetProperty(Reflection_fades, "(Target_item.Opacity)");

Things left are quite simple and easy to understand!
We should let the Storyboard to control our animation, thus we add(hook) it onto the Storyboard.
Of course, we should then add the Storyboard into the Resources so that we can see it in the application.

Reflection_Story1.Children.Add(Reflection_fades);
LayoutRoot.Resources.Add(Reflection_Story1);

Lastly, we should make it starts so we can see what happens to the Opacity of the item.

Reflection_Story1.Begin();

Example is almost finished here, but for more details, you can refer to MSDN.

Because users also need to have a clear concepts of the use of different Animation (like Double, Point…)

Live With Light
Steve Wong (Hong Kong)

2 thoughts on “Animation and Storyboard

  1. I do consider all the ideas you’ve introduced for your post.

    They’re really convincing and can certainly work.
    Still, the posts are very short for starters. May you please lengthen them a bit from
    subsequent time? Thanks for the post.

    Reply

Leave a comment