Click here to Skip to main content
15,860,972 members
Articles / Programming Languages / C#

An Introduction to the Silverlight samples in the All-In-One Framework

Rate me:
Please Sign up or sign in to vote.
5.00/5 (26 votes)
12 Dec 2009Ms-PL5 min read 54.9K   2.2K   56  
This article introduces several Silverlight samples in the All-In-One Framework.
========================================================================
    SILVERLIGHT APPLICATION : CSSL3Animation Project Overview
========================================================================

/////////////////////////////////////////////////////////////////////////////
Use:

This example illustrates how to play animation in Silverlight. Since animation
is a big topic, we only covers PointAnimation in this sample. For other animation
classes, the code should be similar.


/////////////////////////////////////////////////////////////////////////////
Prerequisites:

Silverlight 3 Tools for Visual Studio 2008 SP1
http://www.microsoft.com/downloads/details.aspx?familyid=9442b0f2-7465-417a-88f3-5e7b5409e9dd&displaylang=en

Silverilght 3 runtime:
http://silverlight.net/getstarted/


/////////////////////////////////////////////////////////////////////////////
Code Logic:

1. MainPage.xaml:

It is the container of the following UserControls:
BasicPointAnimation.xaml
AnimateDependencyProperty.xaml
Easing.xaml
CodeBehindCreation.xaml
UsingKeyFrames.xaml

2. BasicPointAnimation.xaml:

It shows how to write baisc PointAnimation for an EllipseGeometry. In the
MouseLeftButtonDown event of MyStackPanel, current mouse position is got and the
To property of PointAnimation object is updated. After that, call Begin() method
of the StoryBoard object to play animation.

3. MyEllipse.xaml:

This UserControl is used to wrap a EllipseGeometry. EllipseGeometry doesn't
expose any event for its Center change. So to get a notification after Center
change EllipseCenterProperty is added. A callback method is hooked so that whenever
the EllipseCenterProperty is changed we can synchronize the changed value with the
Center property of EllipseGeometry object, in which way to update UI.

4. AnimateDependencyProperty.xaml

This UserControl uses MyEllipse UserControl. The TargetProperty of the StoryBoard
in it is the EllipseCenterProperty of MyEllipse object. During the animation, the
EllipseCenterProperty will be changed and the callback method MyHandler() will be 
called, which in turn calls OnEllipseCenterChanged() method to trigger the 
EllipseCenterChanged event. The EllipseCenterChanged event is public so we can hook
event handler in AnimateDependencyProperty UserControl to get a notification for 
EllipseCenterProperty's change. In this sample, a Line object is updated in this
event handler to simulate an animation effect.

5. Easing.xaml

This UserControl demonstrates how to use built-in Ease classes and how to write a
custom Ease class. By inheriting EasingFunctionBase and override its EaseInCore()
method we can write our own Ease class.

6. CodeBehindCreation.xaml

This UserControl shows how to initialize a Storyboard in code behind. The final effect
is the same as BasicPointAnimation.xaml, which uses XAML to add Storyboard.

7. UsingKeyFrames.xaml

This UserControl shows how to create KeyFrames based animation in Silverlight.
In the sample SplineDoubleKeyFrame is used to specify each KeyFrame.


/////////////////////////////////////////////////////////////////////////////
References:

Animation
http://msdn.microsoft.com/en-us/library/cc189090(VS.95).aspx


/////////////////////////////////////////////////////////////////////////////

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
China China
Microsoft All-In-One Code Framework delineates the framework and skeleton of Microsoft development techniques through typical sample codes in three popular programming languages (Visual C#, VB.NET, Visual C++). Each sample is elaborately selected, composed, and documented to demonstrate one frequently-asked, tested or used coding scenario based on our support experience in MSDN newsgroups and forums. If you are a software developer, you can fill the skeleton with blood, muscle and soul. If you are a software tester or a support engineer like us, you may extend the sample codes a little to fit your specific test scenario or refer your customer to this project if the customer's question coincides with what we collected.
http://cfx.codeplex.com/

Comments and Discussions