BusyIndicator

BusyIndicator makes it easy to let the user know when an application is busy. Simply wrap the relevant content in an instance of the BusyIndicator control and toggle its IsBusy property to True during any long-running process.
busyindicator.jpg

Usage

Add namespace:
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"

Default Settings:
<xctk:BusyIndicator IsBusy="True" >
            <ContentControl Style="{StaticResource SampleContent}"/>
</xctk:BusyIndicator>

Custom Message:
<xctk:BusyIndicator IsBusy="True" BusyContent="Downloading email..." >
            <ContentControl Style="{StaticResource SampleContent}"/>
</xctk:BusyIndicator>

Custom Content:
 <xctk:BusyIndicator IsBusy="True" DisplayAfter="0">
       <xctk:BusyIndicator.BusyContentTemplate>
            <DataTemplate>
                 <StackPanel Margin="4">
                          <TextBlock Text="Downloading Email" FontWeight="Bold" HorizontalAlignment="Center"/>
                           <StackPanel Margin="4">
                               <TextBlock Text="Downloading message 4/10..."/>
                               <ProgressBar Value="40" Height="15"/>
                           </StackPanel>
                           <Grid>
                               <Grid.ColumnDefinitions>
                                   <ColumnDefinition/>
                                   <ColumnDefinition/>
                               </Grid.ColumnDefinitions>
                               <Button Grid.Column="0" Content="Pause" HorizontalAlignment="Right" Margin="0 0 2 0"/>
                               <Button Grid.Column="1" Content="Cancel" HorizontalAlignment="Left" Margin="2 0 0 0"/>
                           </Grid>
                  </StackPanel>
            </DataTemplate>
       </xctk:BusyIndicator.BusyContentTemplate>
       <xctk:BusyIndicator.OverlayStyle>
                  <Style TargetType="Rectangle">
                        <Setter Property="Fill" Value="#ffffeeee"/>
                  </Style>
       </xctk:BusyIndicator.OverlayStyle>
       <xctk:BusyIndicator.ProgressBarStyle>
                   <Style TargetType="ProgressBar">
                            <Setter Property="Visibility" Value="Collapsed"/>
                   </Style>
       </xctk:BusyIndicator.ProgressBarStyle>
       <ContentControl Style="{StaticResource SampleContent}"/>
</xctk:BusyIndicator>

Properties

Property Description
BusyContent Gets or sets the busy content to display to the user.
BusyContentTemplate Gets or sets the DataTemplate to use for displaying the busy content to the user.
DisplayAfter Gets or sets the time interval that the busy content is delayed before being displayed.
IsBusy Gets or sets a value indicating whether the busy indicator should be shown.
IsContentVisible Gets or sets a value indicating whether the BusyContent is visible.
OverlayStyle A Style object representing the style to use for the overlay. By default, null.
ProgressBarStyle A Style object representing the style to use for the progress bar. By default, null.


Here is a blog post describing how to use the BusyIndicator in multi-threaded scenarios:

http://elegantcode.com/2011/10/07/extended-wpf-toolkitusing-the-busyindicator/

Support this project, check out the Plus Edition.
---

Last edited May 9 at 8:42 PM by Kosmatos, version 8

Comments

gnlee Jan 9 at 1:42 PM 
BusyIndicator will not display if using reportviewer.
The following code works fine until the "Lineup (Proposed)" is selected.
Any other Tab that does not contain a ReportViewer works as expected.

<xctk:BusyIndicator Name="SchedulerBusyIndicator" BusyContent="Please wait..." >
//..... Additional code for page left out
<TabItem Header="Lineup (Proposed)" >
<WindowsFormsHost Name="winSchedulerFormsHost2">
<wfr:ReportViewer x:Name="rptSchedulerLineupRptViewer" ProcessingMode="Local" />
</WindowsFormsHost>
</TabItem>
.....
</xctk:BusyIndicator>

Any help would be greatly appreciated.

BoucherS Jan 8 at 2:32 PM 
Please use the Discussion Tab !
An issue have been created for BusyIndicator without ProgressBar : https://wpftoolkit.codeplex.com/workitem/19155

Katti Jan 5 at 10:50 AM 
Can we use rotating image in place of progress bar. I really want to use image not bar.. Bar is so native.

jkmchinese Dec 5, 2012 at 11:52 AM 
did not support Binding!

sakeller_us Aug 2, 2012 at 9:28 PM 
I believe the namespace shown in the above XAML is incorrect... should be:
xmlns:tool="clr-namespace:Xceed.Wpf.Toolkit;assembly=WPFToolkit.Extended"

Dk110397 Jul 27, 2012 at 11:30 PM 
After I added reference to the WPFToolKit.Extended dll, I' getting the error : "The type or namespace name 'Windows' does not exist in the namespace 'Microsoft' "

I'm using WPF on .NET 4.0 Client profile.

How can I fix this error?

gerardogc2378 Jul 19, 2012 at 4:34 PM 
I use this piece of code using Silverlight 4


private void MyOwnProcess()
{
BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (o, ea) =>
{
System.Threading.Thread.Sleep(500);


this.Dispatcher.BeginInvoke(() =>
{
Worker(); // Your another method to process async
});
};

worker.RunWorkerCompleted += (o, ea) =>
{
CurrentBusyIndicator.IsBusy = false;
};

CurrentBusyIndicator.IsBusy = true;
worker.RunWorkerAsync();
}

krlbaker May 10, 2012 at 7:11 PM 
Need a little help, I added the reference to my WPF project. I added the namespace in my main window and then wrapped my Grid with the <extToolkit:BusyIndicator>. I am getting the following error "The tag 'BusyIndicator' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit/extended'." I tried to unblock the dll, as someone mentioned on StackOverflow. I am not very WPF literate. Thanks.

jojo_jojo Apr 2, 2012 at 9:14 AM 
And Special thanks to brianlagunas

jojo_jojo Apr 2, 2012 at 9:13 AM 
This is gr8 worrk..Thanks a lot cignum for solving my problem in advance..

cignum Feb 19, 2012 at 1:15 PM 
I am using WPF + PRISM + MVVM pattern.
I had problems since changes made during long-running process execution had to update the UI as a final step.

Solution provided by lnk above was not complete for my scenario since my dispatcher is in the VIEW and long-running-process code is in the VIEWMODEL.

I found the solution here:
http://blogs.msdn.com/b/davidrickard/archive/2010/04/01/using-the-dispatcher-with-mvvm.aspx?CommentPosted=true#commentmessage

I added the following code in my App.Xaml.cs class constructor (pls see class definition in the link above):
DispatchService.DispatchObject = this.Dispatcher;

and then invoked
DispatchService.Dispatch
inside the BackgroundWorker.DoWork method, in order to have the UI updated as a consequence of the methods inside the DoWork code.

so basically in the VM i have:

////////////////////////////////////

BackgroundWorker worker = new BackgroundWorker();
worker.DoWork += (o, ea) =>
{
//long-running-process code
System.Threading.Thread.Sleep(10000);

DispatchService.Dispatch((Action)(() =>
{
//update the UI code goes here
// ...
}));
};

worker.RunWorkerCompleted += (o, ea) =>
{
this.ResetIsBusy(); //here the BusyIndicator.IsBusy is set to FALSE
};
this.SetIsBusy(); //here the BusyIndicator.IsBusy is set to TRUE
worker.RunWorkerAsync();


////////////////////////////////////////////////

hope may help, I spend a night on this! ;)