Simplest way to create busy animation in WPF
Asked Answered
G

6

31

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

Geiger answered 29/5, 2010 at 11:1 Comment(0)
H
12

BizzySpinner 2 – A WPF Spinning Busy State Indicator (with source)

Hawthorn answered 29/5, 2010 at 11:3 Comment(2)
licence is Microsoft Public LicenseHawthorn
How do I add this control to my toolbox ?Geiger
P
19

There's also Sacha Barber's Circular Progress Bar. It's licensed under the Code Project Open License.

Predestine answered 4/1, 2011 at 1:51 Comment(2)
Probably moved to codeproject.com/Articles/49853/Better-WPF-Circular-Progress-BarAdvocaat
Someone in the comments on that page made a no-code-behind version. it's pretty slick. Direct link: fredgrass.blogspot.com/2015/07/wpf-busy-indicator.htmlArtemus
H
12

BizzySpinner 2 – A WPF Spinning Busy State Indicator (with source)

Hawthorn answered 29/5, 2010 at 11:3 Comment(2)
licence is Microsoft Public LicenseHawthorn
How do I add this control to my toolbox ?Geiger
R
10

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.

Reparation answered 24/11, 2013 at 21:4 Comment(0)
D
4

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

Detach answered 2/7, 2014 at 7:21 Comment(0)
P
3

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.

Pape answered 11/12, 2013 at 13:20 Comment(0)
K
0

I recently implemented one that looks like the iPhone busy indicator, explained here.

Kinship answered 19/12, 2011 at 12:19 Comment(2)
Rotates a png file. Not actually drawing. Which, to me, takes away the advantage of WPF where everything is drawn and looks smooth at any scaling.Gothicize
@ClintStLaurent Not everything has to be vector based in WPF. In this case, imaging is simpler to implement and as a bonus, it is more efficient than vector graphics. However, the main point of this technique was changing the animation rate in order to make the visual look "static". So you can certainly 1) pick a different image sized for your use case, 2) swap out the Image with a Path if you'd like. Same technique would still apply.Brahmin

© 2022 - 2024 — McMap. All rights reserved.