![]() |
Web Development »
Silverlight »
Controls
Beginner
License: The Code Project Open License (CPOL)
A simple animation button in SilverlightBy Mohammad DayyanThis article shows you how we can create an animation button in Silverlight. |
C# (C# 3.0), Windows (WinXP, Vista), Visual Studio (VS2008), WPF, Dev
|
|
Advanced Search Add to IE Search |
|
|
|
||||||||||||||||

This is a simple tutorial that shows you how to create an animation button in Silverlight 2. I didn't write the XAML code by myself, I used Expression Blend 2.
For an animation button with three states, we should first create three storyboards.

Then, in each storyboard, we should create a key frame to show the new state, something like this:

Be careful, we mustn't use the key frames like this:

because the animation will show incorrectly.
After that, we should control the animation with events. I used these methods to do that:
private void buttonGrid_MouseEnter(object sender, MouseEventArgs e)
{
Storyboard1.Begin();
}
private void buttonGrid_MouseLeave(object sender, MouseEventArgs e)
{
Storyboard2.Begin();
}
private void buttonGrid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
Storyboard3.Begin();
}
| You must Sign In to use this message board. | |||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 26 Nov 2008 Editor: Smitha Vijayan |
Copyright 2008 by Mohammad Dayyan Everything else Copyright © CodeProject, 1999-2009 Web21 | Advertise on the Code Project |