Simplest way to create busy animation in WPF
-
05-10-2019 - |
문제
I mentioned that there is no standard busy control in 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).
Thank you in advance
다른 팁
There's also Sacha Barber's Circular Progress Bar. It's licensed under the Code Project Open License.
You can also use animated gifs, compare e.g. this site: 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.
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:
`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.
Bind the usercontrol's IsBusy
property to the view-model.
Or - when appropiate - ignore the DP and the Play()
and Pause()
methods and bind the Visibility
property to the view-model.
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. below is a good link for FrameAnimation spin wheel.
http://www.codeproject.com/Articles/29545/FrameBasedAnimation-Animating-multiple-properties
I recently uploaded one to codeplex. It allows you to customize it (even in runtime). You can download it from here. Sample demo also uploaded.
I recently implemented one that looks like the iPhone busy indicator, explained here.