Jaime Rodriguez in this post describes some new features of the SystemTray class in upcoming WP7 Mango release, I won’t repeat them since Jaime’s post is quite explanatory, I’ve instead investigated more the “Progress” feature mentioned on that post.

Here’s how I’ve configured my SystemTray on MainPage.xaml:

<phone:PhoneApplicationPage x:Class="SystemTrayBackground.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
...
shell:SystemTray.BackgroundColor="Blue"
shell:SystemTray.ForegroundColor="Yellow"
shell:SystemTray.Opacity="50"
shell:SystemTray.IsVisible="True"
>

and here’s what needed to display an indeterminate operation with some text:
 
ProgressIndicator indicator = new ProgressIndicator();
indicator.IsVisible = true;
indicator.IsIndeterminate = true;
indicator.Text = "Loading...";
SystemTray.SetProgressIndicator(this, indicator);
image

If you want more control, you can simply use this alternative:
 
ProgressIndicator indicator = new ProgressIndicator();
indicator.IsVisible = true;
indicator.IsIndeterminate = false;
indicator.Value = 0.5;
indicator.Text = "Loading - 50%";
SystemTray.SetProgressIndicator(this, indicator);

image

To remove it, just use:
SystemTray.SetProgressIndicator(this, null);
 
Really no more excuses to hide it ;-)

Technorati Tags: ,,

sabato 4 giugno 2011 12:45