If you have built a Windows Phone app before, you probably used the ProgressIndicator to indicate to the user that something was being done. The ProgressIndicator could show indeterminate dots floating from left to right to indicate that you have no idea how long the operation will take to complete. Or it would show a progress bar that would tell the user how much progress has been made. You could show the ProgressIndicator in code, but most likely used xaml.
<shell:SystemTray.ProgressIndicator>
<shell:ProgressIndicator IsIndeterminate="True" Text="Loading"
IsVisible="{Binding Loading}" />
</shell:SystemTray.ProgressIndicator>
The new Windows Phone 8.1 Apps for XAML also includes the ability to show progress with a ProgressIndicator, now called StatusBarProgressIndicator. Unlike Phone apps built with Silverlight, the new Phone 8.1 SDK does not include a way to interact with the StatusBarProgressIndicator in XAML. You must use the StatusBar static class to work with the StatusBarProgressIndicator.
StatusBarProgressIndicator progressbar = StatusBar.GetForCurrentView().ProgressIndicator;
The table below shows the differences between the ProgressIndicator and the StatusBarProgressIndicator.
ProgressIndicator |
StatusBarProgressIndicator |
Comments |
string Text |
string Text |
|
double Value |
double? ProgressValue |
When the value is null, shows indeterminate dots |
bool IsVisible |
IAsyncAction ShowAsync()
IAsyncAction HideAsync() |
Two methods replace the single DependencyProperty |
bool IsIndeterminate |
|
replaced with the nullable double ProgressValue |
As you can see, the API for the ProgressIndicator has changed a lot. Where the Silverlight API has four dependency properties, the new API has two. The IsVisible property has been replaced with two async methods. With these changes, if you want to show progress, you’ll have to do it in code.
StatusBarProgressIndicator progressbar = StatusBar.GetForCurrentView().ProgressIndicator;
progressbar.Text = "Loading";
progressbar.ShowAsync();
This stinks if you want to control the loading state from a view model. But the API is accessible from a static class, so you can access the StatusBarProgressIndicator from a view model, provided your view model is not in a portable class library.
You can download a sample that shows controlling the StatusBarProgressIndicator.
Overall this kind of stinks.There must be a better way, right? Read Part 2: Using a behavior to control the ProgressIndicator in Windows Phone 8.1 XAML Apps.