简体   繁体   English

在WPF中创建繁忙动画的最简单方法

[英]Simplest way to create busy animation in WPF

I mentioned that there is no standard busy control in WPF. 我提到WPF中没有标准的忙控制。 So what's the easiest way to display animated busy circle (not progress bar) such as your browser displays when loading a page ? 那么,在加载页面时,显示动画繁忙圈(不是进度条)的最简单方法是什么,例如浏览器显示?

Please if you suggest downloading control from internet make sure that this control is for free and with no licence restriction (such as I would be forced to GPL my application if I use it). 如果你建议从互联网下载控制,请确保这个控件是免费的,没有许可限制(如果我使用它,我将被迫使用GPL我的应用程序)。

Thank you in advance 先感谢您

There's also Sacha Barber's Circular Progress Bar . 还有Sacha Barber的循环进度栏 It's licensed under the Code Project Open License. 它是根据Code Project Open License获得许可的。

You can also use animated gifs, compare eg this site: http://www.loadinfo.net/ . 你也可以使用GIF动画,比较一下这个网站: http//www.loadinfo.net/ Different colors, forms, frames per second, transparant background are generated for you. 为您生成不同的颜色,表格,每秒帧数,透明背景。

Then you add the WPF Animated GIF as a reference to your project. 然后添加WPF动画GIF作为项目的参考。

Make a usercontrol with <Image gif:ImageBehavior.AnimatedSource="Images/animated.gif" /> as its content and give the usercontrol a dependencyproperty (DP) IsBusy with a callback to a method in the usercontrol: 使用<Image gif:ImageBehavior.AnimatedSource="Images/animated.gif" />作为其内容进行用户控制,并为usercontrol一个依赖IsBusy (DP) IsBusy ,并对usercontrol中的方法进行回调:

`public static readonly DependencyProperty IsBusyProperty = DependencyProperty.Register("IsBusy", typeof(bool), typeof(SpinProgress), new FrameworkPropertyMetadata(new PropertyChangedCallback(OnIsBusyChangedCallBack)));`

In this method the animated gif's Play() and 'Pause()' methods can be executed. 在这种方法中,可以执行动画gif的Play()和'Pause()'方法。
Bind the usercontrol's IsBusy property to the view-model. 将usercontrol的IsBusy属性绑定到视图模型。

Or - when appropiate - ignore the DP and the Play() and Pause() methods and bind the Visibility property to the view-model. 或者 - 适当时 - 忽略DP和Play()Pause()方法,并将Visibility属性绑定到视图模型。

You can implement processing wheel while your application is busy. 您可以在应用程序繁忙时实施处理轮。 although WPF do not support any GIF images so you've to use animation for this. 虽然WPF不支持任何GIF图像,但您必须使用动画。 below is a good link for FrameAnimation spin wheel. 下面是FrameAnimation旋转轮的一个很好的链接。

http://www.codeproject.com/Articles/29545/FrameBasedAnimation-Animating-multiple-properties http://www.codeproject.com/Articles/29545/FrameBasedAnimation-Animating-multiple-properties

I recently uploaded one to codeplex. 我最近上传了一个到codeplex。 It allows you to customize it (even in runtime). 它允许您自定义它(即使在运行时)。 You can download it from here . 你可以从这里下载。 Sample demo also uploaded. 样本演示也上传了。

我最近实现了一个看起来像iPhone繁忙指示器, 这里解释。

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

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