Click here to Skip to main content
Licence CPOL
First Posted 26 Nov 2008
Views 29,290
Downloads 842
Bookmarked 44 times

A simple animation button in Silverlight

By Mohammad Dayyan | 26 Nov 2008
This article shows you how we can create an animation button in Silverlight.

1

2
2 votes, 16.7%
3
4 votes, 33.3%
4
6 votes, 50.0%
5
4.68/5 - 12 votes
2 removed
μ 4.37, σa 1.36 [?]

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



Iran (Islamic Republic Of) Iran (Islamic Republic Of)

Member


Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 3 PinmemberJyo-k19:03 23 Dec '10  
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    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web02 | 2.5.120210.1 | Last Updated 26 Nov 2008
Article Copyright 2008 by Mohammad Dayyan
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid