BusyIndicator

Derives from ContentControl

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.
FocusAfterBusy Gets or sets a control that should get focus when the busy indicator disappears.
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 Gets or sets a Style object representing the style to use for the overlay. By default, null.
ProgressBarStyle Gets or sets 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 29 at 3:42 PM by dlafontaine, version 9

Comments

jhoop2002 Aug 13 at 5:20 PM 
I would like to know how other seem to be able to get this control to work? I've followed the instructions to the letter, and it doesnt work. I keep getting an error - "xctk:BusyIndicator was not found. Verify that you are not missing an assemlby reference and that all referenced assemblies have been built."

I even adjusted the xaml based on the comments here to xmlns:xctk="clr-namespace:Xceed.Wpf.Toolkit;assembly=WPFToolkit.Extended" but i get the same error.

I have added the .dll files from the download on this page and referenced them in my project.

What I am doing wrong/not doing?

vdohnal Feb 28 at 7:57 AM 
When I set IsBusy to true and then back to false and I have TabPanel with TabItems on screen then some of my TabItem controls remain disabled (3 of 7). I can see no clue why this happens.

BoucherS Jan 22 at 1:45 PM 
Hi, Discussion Tab https://wpftoolkit.codeplex.com/discussions/520385 has been created.

kprzywara Dec 30, 2013 at 2:33 PM 
Hi - I got everything working fine except 1 piece with updating the status text in the textblock tag.

I use PropertyChanged event to set the value for the progressbar successfully. When I try to do the same for the textblock Text property, it never updates.

<TextBlock Text="{Binding BusyText}" /> //this doesnt work
<ProgressBar Value="{Binding value}" Height="15"/> // this works fine

I used the example from below link to update the property for the ProgressBar.
http://social.msdn.microsoft.com/Forums/silverlight/en-US/8b77e36f-2137-4072-9a66-540301f2a6ea/progressbar-on-busyindicator-doesnt-update-when-value-changes?forum=silverlightcontrols

MarkWain Dec 8, 2013 at 9:22 AM 
I can use the dll in general. However, I have a problem with BusyIndicator. Based on Usage as follows: Add namespace: xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" Default Settings: <xctk:BusyIndicator IsBusy="True" > <ContentControl Style="{StaticResource SampleContent}"/> </xctk:BusyIndicator> I got the error message: "The name 'BusyIndicator' does not exist in the Namespace "http://schemas.xceed.com/wpf/xaml/toolkit".' One of the possible reasons why could be that the BusyIndicator was moved out of the .dll. I wish the author or someone else would help.

I also tried to use xmlns:tool="clr-

namespace:Xceed.Wpf.Toolkit;assembly=WPFToolkit.Extended", it does not work either.

gnlee Jan 9, 2013 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, 2013 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, 2013 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! ;)