SIGN UP MEMBER LOGIN:    
ARTICLE

Ghost Effect In Blend 3 and Silverlight 3

Posted by Diptimaya Patra Articles | XAML with C# July 14, 2009
Making Ghost Effect In Blend 3 and Silverlight 3.
Reader Level:
Download Files:
 

Introduction

This is an effect everybody are imagined of, so I decided to create a simple article to understand better. Ghosting is an effect that is used in a lot of interactive applications-you click a button or element, and a copy of the element scales up and fades out over a second or two. This lets a user know that the action they took was recognized. The effect can also be used when an application first loads in order to draw attention to a particular part of the interface.

Creating the Silverlight Project

mainimage.gif

Start creating a new Silverlight3 Application and Name the Application as GhostEffectMaking.
We will start with a Ghost Effect for a TextBlock.

Ghost Effect for Text

  1. Add a TextBlock to the Grid Layout. (Note: You can add it to any container you need.)

  2. image1.gif
     

  3. Copy the TextBlock and Paste it in the same place.

    image2.gif
     
  4. Select the newly copied TextBlock and create a StoryBoard. Name it as Ghost_MouseOver.

    image3.gif
     
  5. Now recording for the StoryBoard will start. Here you need to Click on the timeframe 1 sec. 

    image4.gif
     
  6. Change the following Properties of the txtLink_Copy, such as In Scale Transform X and Y to 3 and Opacity to 0. 

    image5.gif
     
  7. Close the StoryBoard and make this control's Visibility to Collapsed.

    image6.gif
     
  8. Now it's time to see the animation. Add an event listener to the MouseUp event of txtLink.

    image7.gif
     
  9. Add the following lines of code to the event.

    txtLink_Copy.Visibility= Visibility.Visible;
    Ghost_MouseOver.Begin();

    Behind the scenes, the animation actually does play each time you click. However, you can't see it because the first time the animation plays, the opacity value of the object is animated to a value of 0, and is left there when the animation completes. So every other time you click the object, the animation plays, but the object is totally transparent. This can be fixed by listening for the storyboard to finish and then resetting the object's state.
  10. Now go to your XAML code behind and find the StoryBoard named Ghost_MouseOver. Add an event called Completed.

    image8.gif

    Press Enter to add the event handler as Completed="Ghost_MouseOver_Completed".
     
  11. Navigate to the above function and add the following lines of code. So that each time you click on the text you will be able to see the animation.

    private
    void Ghost_MouseOver_Completed(object sender, EventArgs e)

            {

                txtLink_Copy.Visibility = Visibility.Collapsed;

                Ghost_MouseOver.Stop();

                txtLink_Copy.Opacity = 1;
            }

    You will get the final effect as follows.

    image9.gif

Remember, you can play with different colors. Enjoy Animating.

Login to add your contents and source code to this article
share this article :
post comment
 

Yar jara mujhe bhi sikha de .. ye Ghostinga nd UnGhosting... OPPS not of SharePoint ... of Belnd boss. :)


 Jokes Apart , Nice article... 

Posted by Dhananjay Kumar Jul 14, 2009
Team Foundation Server Hosting
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
Become a Sponsor