Wednesday, January 27, 2016

Working with the StatusBar of the Windows Phone 8.1






Hello everyone !
This blog explains the purpose of Status Bar in Windows Phone 8.1 and how we can leverage it our apps using C# and XAML to give a good user experience.

StatusBar is that area of the phone where information related to battery, network strength is shown.
Let's a look of what the different icons on the StatusBar represent.


The StatusBar can be customized as per our needs to show information or show a progress bar for an indeterminate activity.
Practically, a progress indicator is shown on the StatusBar in every app where data is being loaded on the page or when listviews are refreshed while getting data from a web service.

The StatusBar class is in the Windows.UI.ViewManagement namespace and it provides methods and properties for interacting with status bar on a window (app view).

1. Obtain a reference of the StatusBar class and calls its ShowAsync() method
var statusBar = StatusBar.GetForCurrentView();
await statusBar.ProgressIndicator.ShowAsync();

2.Optionally you can change its background but the opacity has be set at the same time otherwise the StatusBar won't show up.
statusBar.BackgroundColor = Colors.Firebrick;
statusBar.BackgroundOpacity = 1;

3.You can also show a Progress Indicator with a text.
statusBar.ProgressIndicator.Text = "getting information";
await statusBar.ProgressIndicator.ShowAsync();

4.If you want to only show text without the progress indicator then that can be done by :
statusBar.ProgressIndicator.ProgressValue = 0;

5.To hide the ProgressIndicator :
await statusBar.ProgressIndicator.HideAsync();

6.To hide the StatusBar completely :
await statusBar.HideAsync();



Download the source code :-)

No comments :

Post a Comment