Built-in Progress Indicator in System Tray

In this post I will show how to use built-in progress indicator which will be shown on top of the page (in system tray). Like I said it is built-in, all we have to do is call it when we need it. It is Mango only feature, so if you are developing for earlier versions, Progress Indicator will be unavailable.

Using Progress Indicator

Displaying Progress Indicator is fairly simple. All we have to do is create an instance of ProgressIndicator object and add it to system tray.

We can show Progress Indicator in two different modes:  Indeterminate and  Determinate.  Indeterminate mode is when Progress Indicator is indicating that app is doing  something in the background, but there is no progress shown (progress indicator is looping). Determinate mode is when progress is displayed.

To be able to use Progress indicator first thing to do is to add a using:

 using Microsoft.Phone.Shell; 

Indeterminate mode

Show  Indeterminate Progress Indicator

ProgressIndicator progInd = new ProgressIndicator();
 progInd.IsIndeterminate = true;
 progInd.Text = "Indeterminate progress indicator sample";
 progInd.IsVisible = true;

 SystemTray.SetProgressIndicator(this, progInd); 

Hide Progress Indicator:


SystemTray.SetProgressIndicator(this, null); 

Indeterminate Progress Indicator

Determinate mode

Showing progress indicator in tray with zero progress

 progInd.IsIndeterminate = false;
 progInd.Text = "Determinate progress indicator sample";
 progInd.Value = 0;
 progInd.IsVisible = true;

 SystemTray.SetProgressIndicator(this, progInd); 

Adding progress value (value is in range: 0-1)

 progInd.Value = progInd.Value + 0.1; 

Hide progress indicator

 SystemTray.SetProgressIndicator(this, null); 

Determinate Progress Indicator

Source code

Download source here.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s