Popups and dialogs
It is not uncommon to want to alert the user to a condition or change or to get back a bit of data from the user with an alert, as shown in Figure 4.22:
Figure 4.22 – The Alert dialog
To keep things clean, remove the Editor and its associated Label from LoginPage.xaml
and remove the constructor and ICommand
from ViewModel
. We won’t need them in the final version.
The DisplayAlert
object can only be called from a page. Later, you’ll see how to handle SubmitCommand
on the Button in ViewModel
and send a message to the page to show the alert. For now, let’s keep things simple, and change the Button’s SubmitCommand
to an event:
<Button BackgroundColor="Gray" Clicked="OnSubmit" Margin="5" Text="Submit" />
The event handler is placed in the code-behind file. Notice...