Simple StatusBar on Windows 10 Mobile

24 March 2016

Simple status bar uwp

The default StatusBar on Windows Phone and Windows 10 Mobile contains all types of icons. WLAN + Cellular Status, Bluetooth, Flight Mode and so on ...

If you want to display the StatusBar when your app is opened but reduce the noise all the icons produce, you can use the following hack so it only displays the current time (on the right):

// check if the status bar is available (will be false on desktop)
if (ApiInformation.IsApiContractPresent("Windows.Phone.PhoneContract", 1, 0))
{
  StatusBarProgressIndicator indicator = StatusBar.GetForCurrentView().ProgressIndicator;

  // show the progress indicator and set it's value to 0.
  await indicator.ShowAsync();
  indicator.ProgressValue = 0;

  // the space here is the required hack,
  // as it will hide all other controls to make room for the progress text,
  // which is invisible here because it's only a space
  indicator.Text = " ";
}

Don't forget to add Windows Mobile Extensions for the UWP so you get access to the StatusBar.

The StatusBar contains a ProgressIndicator. You probably have already seen the moving dots when content is loading. If you set ProgressValue the bar will become intermediate and in our case invisible because its value is zero. The last step is to set the Text property to a space char, so the other icons disappear.

Demo project can be found on github: SimpleStatusBar UWP

That's it ;-)

comments powered by Disqus