Last week I got into a conversation with Christine Blanda on the Xamarin Forms forum about creating a page that had a built-in Activity Indicator that could be enabled/disabled by just setting properties. It turns out that I was at a point in one of my projects where I needed just such a component so I spent a little time, and with Christine’s help, and created WaitingPage.
The source is available on GitHbg and will probably be integrated in with the XLabs project after a little more testing and feedback.
The following properties are available:
IsWaiting (bool, bindable)
true Shows the waiting indicator, false hides the waiting indicator.
ShowLoadingFrame (bool, bindable)
true Wraps the waiting indicator in a frame. false simply shows the waiting indicator by itself.
ShowLoadingMessage (bool, bindable)
true Shows a message along with the waiting indicator, false simply shows the waiting indicator by itself.
ShadeBackground (bool, bindable)
true will shade the background of the page a light grey while the indicator is active, false will not employ shading.
LoadingMessage (string, bindable)
Allows you to specify a waiting message along with the waiting indicator. The default is Loading….
WaitingOrientation (StackOrientation, bindable)
Shows the waiting indicator either vertically or horizontally. If you only have the indicator, this properly is pretty much ignored. But if you are using a waiting message, it will display the message above the indicatore (vertical) or to the right of the indicator (horizatontal).
You may specify your own pre-created ActivityIndicator if you wish. If one is not specified, a new one will be created.
Just inherit from WaitingPage instead of ContentPage:
public class LoginPage : WaitingPage
Then set the various properties:
ShowLoadingFrame = true; ShowLoadingMessage = true; ShadeBackground = false; LoadingMessage = “Logging in…”; IsWaiting = false; WaitingOrientation = StackOrientation.Vertical;
To show the indicator immediately when the page appears, just set IsWaiting to true.
To hide the indicator, just set IsWaiting to false.