Monthly Archives: October 2011
Using the System Tray to show progress in Windows Phone 7 Mango
Before Mango it was a little difficult to put a generic status message at the top of your page. The Mango tools have made this a bit easier by giving developers (more) access to the System Tray. That’s this part:
You are still a bit limited in what you can do (i.e. you can’t actually add or remove icons), but there’s a lot more flexibility than before.
You can access the system tray either in code or XAML using the Microsoft.Shell.SystemTray class. This class has the following dependency properties:
- IsVisible
- Opacity
- BackgroundColor
- ForegroundColor
- ProgressIndicator
While it’s quite exciting to be able to style the status bar, I cried out of joy when I saw the ProgressIndicator property. Why…? Because now I can add progress information to the top of my pages quickly and easily! J
So, I want to add a downloading message and progress bar to the top of my page (above the application title) as follows:
Using XAML, I can add text and a progress bar to a page by dropping the following into the page:
<shell:SystemTray.ProgressIndicator> <shell:ProgressIndicator IsIndeterminate="true" IsVisible="True" Text="Click me..." /> </shell:SystemTray.ProgressIndicator>
Or, using code, I can accomplish the same thing by dropping this into my code:
ProgressIndicator progress = new ProgressIndicator { IsVisible = true, IsIndeterminate = true, Text = "Downloading details..." }; SystemTray.SetProgressIndicator(this, progress);
Feel free to download my sample application showing how to manipulate the System Tray: