Click here to Skip to main content
6,633,937 members and growing! (20,637 online)
Email Password   helpLost your password?
Web Development » Silverlight » Controls     Beginner License: The Code Project Open License (CPOL)

A simple animation button in Silverlight

By Mohammad Dayyan

This article shows you how we can create an animation button in Silverlight.
C# (C# 3.0), Windows (WinXP, Vista), Visual Studio (VS2008), WPF, Dev
Posted:26 Nov 2008
Views:12,636
Bookmarked:28 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
9 votes for this article.
Popularity: 4.19 Rating: 4.39 out of 5

1

2
1 vote, 11.1%
3
3 votes, 33.3%
4
5 votes, 55.6%
5

Introduction

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.

Using the code

For an animation button with three states, we should first create three storyboards.

silverlight animation button

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

silverlight animation button

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

silverlight animation button

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();
}

History

  • 27th November, 2008: First post.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Mohammad Dayyan


Member

Location: Iran, Islamic Republic Of Iran, Islamic Republic Of

Other popular Silverlight articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 4 of 4 (Total in Forum: 4) (Refresh)FirstPrevNext
Generalfeedback Pinmemberdk gohel0:23 20 Mar '09  
GeneralNice, but I think you should creat a new template for your button Pinmembercokkiy2:53 2 Dec '08  
GeneralRe: Nice, but I think you should creat a new template for your button Pinmemberwaged11:02 3 Jul '09  
GeneralRe: Nice, but I think you should creat a new template for your button Pinmembercokkiy6:03 5 Jul '09  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin 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