Click here to Skip to main content
5,787,682 members and growing! (21,066 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, C#), Windows (Windows, WinXP, Vista), Visual Studio (VS2008, Visual Studio), WPF, Dev

Posted: 26 Nov 2008
Updated: 26 Nov 2008
Views: 3,427
Bookmarked: 16 times
Announcements
Loading...



Search    
Advanced Search
Sitemap
7 votes for this Article.
Popularity: 3.93 Rating: 4.65 out of 5
0 votes, 0.0%
1
0 votes, 0.0%
2
0 votes, 0.0%
3
3 votes, 42.9%
4
4 votes, 57.1%
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



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

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 1 of 1 (Total in Forum: 1) (Refresh)FirstPrevNext
GeneralNice, but I think you should creat a new template for your buttonmembercokkiy2:53 2 Dec '08  

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
Web11 | Advertise on the Code Project