Visually Located


Differences between the new StatusBar in Windows Phone XAML Apps and the SystemTray

With the release of Windows Phone 8.1 SDK comes a new StatusBar. The StatusBar replaces the SystemTray from Windows Phone Silverlight Apps. Unlike the SystemTray, the StausBar can only be accessed via code and some functionality has changed. This post will go in depth on how to access the the StatusBar and what the differences are.

Just like the new StatusBarProgressIndicator, you can only access the StatusBar via code with the GetForCurrentView method.

StatusBar statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();

Once you have the StatusBar, you have access to the same capabilities as you did before, with a few changes. The table below shows

SystemTray StatusBar Comments
System.Windows.Media.Color ForegroundColor Windows.UI.Color? ForegroundColor  
System.Windows.Media.Color BackgroundColor Windows.UI.Color? BackgroundColor  
bool IsVisible IAsyncAction HideAsync()
IAsyncAction ShowAsync()
Two methods replace the single DependencyProperty
double Opacity double BackgroundOpacity Does not shift content up when value is less than 1
  event Hiding New!
  event Showing New!


The biggest different in the table above is not the new events, it’s not the change from IsVisible to the new methods. The biggest difference is the change is functionality in setting the opacity. In Windows Phone Silverlight Apps, when you set the Opacity to a value less that 1, the page content shifts up into the space of the tray. Now when you set the BackgroundOpacity the page content does not shift up. I like this change as it makes the opacity property of all other XAML controls. So how do you shift content up into the status bar area? This functionality is still available, and like the rest of the StatusBar, is only accessible in code. The ApplicationView class provides this functionality with the SetDesiredBoundsMode method.


The BackgroundOpacity also defaults to 0 which means that only setting the BackgroundColor will not change the background. You must also set the opacity to the desired value.

var statusBar = StatusBar.GetForCurrentView();
statusBar.BackgroundOpacity = 1;
statusBar.BackgroundColor = Colors.Red;

Just like the new StatusBarProgressIndicator, the StatusBar lost the IsVisible property in favor of two async methods to set visibility.

StatusBar statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
// Hide the status bar
await statusBar.HideAsync();
//Show the status bar
await statusBar.ShowAsync();

The status bar does have two new events for when the status bar is shown or hidden!

The rest of the StatusBar is very similar to the SystemTray. You even have access to the new StatusBarProgressIndicator.

StatusBar statusBar = Windows.UI.ViewManagement.StatusBar.GetForCurrentView();
StatusBarProgressIndicator progress = statusBar.ProgressIndicator;
If you are not a fan with accessing the StatusBar in code only, you can create a behavior for accessing it in XAML.
blog comments powered by Disqus