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

Ras*_*sto 29 c# wpf components busyindicator

我提到WPF中没有标准的忙控制.那么,在加载页面时,显示动画繁忙圈(不是进度条)的最简单方法是什么,例如浏览器显示?

如果你建议从互联网下载控制,请确保这个控件是免费的,没有许可限制(如果我使用它,我将被迫使用GPL我的应用程序).

先感谢您

dth*_*her 18

还有Sacha Barber的循环进度栏.它是根据Code Project Open License获得许可的.

  • 该页面评论中的某人制作了无代码隐藏版本.它很漂亮.直接链接:http://fredgrass.blogspot.com/2015/07/wpf-busy-indicator.html (3认同)
  • 可能转移到http://www.codeproject.com/Articles/49853/Better-WPF-Circular-Progress-Bar (2认同)

Ger*_*ard 8

你也可以使用GIF动画,比较一下这个网站:http://www.loadinfo.net/.为您生成不同的颜色,表格,每秒帧数,透明背景.

然后添加WPF动画GIF作为项目的参考.

使用usercontrol <Image gif:ImageBehavior.AnimatedSource="Images/animated.gif" />作为其内容,并为usercontrol提供一个dependencyproperty(DP),IsBusy其中包含对usercontrol中方法的回调:

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

在这种方法中,Play()可以执行动画gif 和'Pause()'方法.
将usercontrol的IsBusy属性绑定到视图模型.

或者 - 适当时 - 忽略DP和Play()and Pause()方法并将Visibility属性绑定到视图模型.