ARTICLE

Busy Indicator Control In Silverlight 3

Posted by Diptimaya Patra Articles | Silverlight with C# November 25, 2009
Busy Indicator is a control that is added in Silverlight 3 Toolkit November 2009 Release. In this article we will see how to use it.
Reader Level:
Download Files:
 

Introduction

Busy Indicator is a control that is added in Silverlight 3 Toolkit November 2009 Release. In this article we will see how to use it.

Creating the Silverlight Application

Fire up Visual Studio 2008 and create a Silverlight Application, name it as BusyIndicatorSample.

1.gif

Open your application in Blend 3.

Add some controls to your application. I have added one Button and a TextBox control.

2.gif

Now add a Busy Indicator Control to your application. Before adding it your application you need to take care of something:

  • Always add the Busy Indicator as your last control in the order. In our case it's in the order
    • TextBox
    • Button
    • BusyIndicator
  • Always make the Busy Indicator's Horizontal and Vertical Alignment to Stretch so that it covers the whole Parent Panel. In our case it's Grid[LayoutRoot]
Now you are ready to add the Busy Indicator.

3.gif

After adding it you can see several properties associated to it.

4.gif

You can remove the Content and add your own message in BusyContent.

Now we will add some code in the Button Click event and we will see how it is effective to use BusyIndicator Control.

Name the BusyIndicator as BusyWindow.

<
Button x:Name="btnLoad" Click="btnLoad_Click"
            Height="25" HorizontalAlignment="Left" Margin="30,97,0,0" VerticalAlignment="Top" Width="100" Content="Save Data"/>
          <TextBox Height="25" HorizontalAlignment="Left" Margin="30,41,0,0" VerticalAlignment="Top" Width="200" TextWrapping="Wrap"/>
          <controlsToolkit:BusyIndicator x:Name="BusyWindow" Content="" BusyContent="Please Wait While Saving Data..."/>

private
void btnLoad_Click(object sender, RoutedEventArgs e)
{
    int busyDisplay = 3;
    int delayDisplay = 500;
    BusyWindow.DisplayAfter = TimeSpan.FromMilliseconds(delayDisplay);
    BusyWindow.IsBusy = true;
    ThreadPool.QueueUserWorkItem((state) =>
        {
            Thread.Sleep(busyDisplay * 1000);
            Dispatcher.BeginInvoke(() => BusyWindow.IsBusy = false);
        });
    txtStatus.Text = "Data Saved";
}

Now run your application and type some text in the TextBox and then click on the Save Data Button.

5.gif
 
Now you would understand why we made the Alignment of BusyIndicator as Stretch. If you don't make it, the controls would be available for user to operate on.

Hope you like this article.

Login to add your contents and source code to this article
post comment
     

If you could explain, in more detail, the threading that you used in this example that would be a great help!


Thanks,

Will

Posted by Will Reynolds Jun 29, 2010

Busy Indicator is not included in your version of toolkit. Try Silverlight 3 Toolkit November 2009 release.

Thanks
Diptimaya Patra

Posted by Diptimaya Patra Mar 22, 2010

I have silverlight tookit version 3.0 Jully 2009 loaded on my machine but there is no control in Blend called Busyindicator.

Posted by Edward Joell Mar 22, 2010

Hey Diptimaya, Thanks for this write up.

Simple and easy to use.

Regards

KRK

Posted by Raghuraman Kanchi Jan 19, 2010
COMMENT USING
PREMIUM SPONSORS
DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and add new content to existing PDF documents from within your applications.
Get Career Advice from Experts
SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.