dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersUltimaterengan
malika
Dinesh Kudale
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Resources » .NET programming » WPF

How to do Animation in WPF


Posted Date:     Category: WPF    
Author: Member Level: Gold    Points: 25


This article will help to create different kind of animation for the application. In this article we will discuss about the different kind of animation in wpf. Also why animation required and the cases where we can have animation.



 


Why Animation Required?



Now day's user will need more interactive and graphics oriented application. We have to develop or use some times animation as well to make application more attractive so it will also help somehow to sale application.

Cases:



Long Running Process
Status of Running Program
Highlighting the special objects
Progression of Activity


Implementation



Double Animation

Double Animation can be applied to any double property of a control like Opacity, Height and Width RadiusX,RadiusY and more. Things to remember in double animation are properties of double animation.

TargetName = Control Name where we want to apply animation. E.g. myEllipse
TargetProperty = Property of a control like Opacity and discussed above.
From = Start Value
To = End Value
Duaration = Time span value
RepeatBehavior : Is it Required to Repeat.



<StackPanel Margin="10">
<Ellipse Name="myEllipse" Width="75" Height="75" Fill="Black">
<Ellipse.Triggers>
<EventTrigger RoutedEvent="Ellipse.Loaded">
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetName="myEllipse"
Storyboard.TargetProperty="Opacity"
From="1.0" To="0.2" Duration="0:0:5"
AutoReverse="True" RepeatBehavior="Forever" />
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Ellipse.Triggers>
</Ellipse>
</StackPanel>



Color Animation

This is used to animate the color of a control. And it can be applied to a SolidColorBrush, GradiantColor and Background as well.


<StackPanel Margin="10">
<Ellipse Name="myEllipse" Width="75" Height="75">
<Ellipse.Fill>
</Ellipse.Fill>
<Ellipse.Triggers>
<EventTrigger RoutedEvent="Ellipse.MouseEnter">
<BeginStoryboard>
<Storyboard>
<ColorAnimation
Storyboard.TargetName="elpBrush"
Storyboard.TargetProperty="Color"
From="LightGray" To="Black" Duration="0:0:1"
/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Ellipse.Triggers>
</Ellipse>
</StackPanel>



Note : This is very simple way to do animation now here innovation and creativity required more things to use it. Also one thing most of the time we are going to create animation for progress bar kind of thing but we can also use wpf extended toolkit busy indicator to do that task.





Did you like this resource? Share it with your friends and show your love!


Responses to "How to do Animation in WPF"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: How to Implement MVVM
    Previous Resource: WPF – Different Kind of Binding
    Return to Resources
    Post New Resource
    Category: WPF


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Wpf Animation  .  How to do Animation  .  Double Animation  .  Color Animation  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.