简体   繁体   English

如何在WPF中的C#上放置动画效果

[英]How to put animation effects on C# in WPF

I am using wpf application where i am using an image. 我在使用图像的地方使用wpf应用程序。 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 我可以在这里使用Silverlight或Flash或其他方法吗

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 您也可以在xaml中完成

If you want to know when its completed add a listener to the completed event of the animation 如果您想知道动画何时完成,请将侦听器添加到动画的完成事件中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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