I have a non modal page where the user enters data. If the user clicks the software back button (popping the task) before saving his entered data I want to ask the user if they want to save the data.
I can do this by overriding OnDisappearing like so:
async protected override void OnDisappearing ()
{
//base.OnDisappearing ();
if (UnsavedData ()) {
bool answer = await DisplayAlert ("Unsaved Changes", "Would you like to save your changes?", "Yes", "No");
if (answer) {
PersistChanges ();
}
}
}
The problem I am running into is that before PersistChanges is called, my code returns to previous screen.
What can I do to delay the pop until after PersistChanges executes?
Thank you.