I have a multi-page (Android & iOS) Xamarin.Forms app following the MVVM pattern. From time to time the business logic may invoke an important activity, like trigger a data synchronization with some web service. I't like to show the user that there's something going on in the background. An ActivityIndicator in the Toolbar would be my ideal solution. The activity isn't related to the page in the foreground, so I don't want to put the indicator on the page, I want it somewhere outside, the Toolbar seems to be the right spot.
My first attempt was via XAML:
<ContentPage.ToolbarItems>
<ToolbarItem>
<ActivityIndicator IsRunning="{Binding IsRunning}" />
</ToolbarItem>
</ContentPage.ToolbarItems>
While this (and similar approaches) compiles, it will throw an exception, seems like an ActivityIndicator may no way be a child of ToolbarItems or any Toolbar Item.
Flipping man pages I stumbled across the IsBusy property of the page class.
https://developer.xamarin.com/api/property/Xamarin.Forms.Page.IsBusy/
To try, I used this code:
public App ()
{
InitializeComponent();
MainPage = new App1.MainPage();
MainPage.IsBusy = true;
}
The result is - nothing. No error, but nothing displays in the Toolbar. I found some indication in forums that this functionality was probably discarded in the newest Android versions, but nothing definite, and the docs don't say so.
How can I achieve what I want?