简体   繁体   中英

How to put animation effects on C# in WPF

I am using wpf application where i am using an image. I want to put some animation effects on it. When a user clicks on button it dissapear from the screen and move away from left to right or some this kind of animation. What classes do i need to use. Can I use silverlight or flash or something else here

DoubleAnimation TopAnimation = new DoubleAnimation();
TopAnimation.From = YourImage.Top;
TopAnimation.To = WhereYouWantItToEndUp
TopAnimation.Duration = TimeSpan.FromSeconds(AnDuration);

YourImage.BeginAnimation(YourImage.TopProperty, TopAnimation);

And you can chain a bunch of them together and they will all happen at the same time.

You can also do it in xaml

If you want to know when its completed add a listener to the completed event of the animation

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM