In this article we will see how to use set the visibilit, background color and foreground color of SystemTray in Windows Phone 7. We will also see how to use Progress Indicator in SystemTray.
When working with colors in system tray we should take consideration of theme which is set on the device. In fact we should set the background and foreground color of system tray based on the theme.
Below background and foreground color of system tray has been set without consideration of theme.
Let's write code
SystemTray and ProgressIndicator is part of Microsoft.Phone.Shell namespace. Add Microsoft.Phone.Shell using directive in MainPage.xaml.cs.
I have already mentioned in my last article how to Detect Theme.
In the below code I have used constructor of the page to show the system tray and set background and foreground color. One can use button or checkbox or slider to set the visibility of system tray.
Once you create the ProgressIndicator it needs to be added in the SystemTray using SetProgressIndicator.
Place the below code in the constructor of MainPage.
Visibility v = (Visibility)Resources["PhoneLightThemeVisibility"];
if (v == System.Windows.Visibility.Visible)
prog = new ProgressIndicator();
prog.IsVisible = true;
prog.IsIndeterminate = true;
prog.Text = "System Tray Color Based on theme.......";
Now run the application. SystemTray and ProgressIndicator is on dark theme.
Now change the theme to light.
This end the article of setting visibility, ProgressIndicator, Background and Foreground Color of SystemTray.