Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 89864

Overriding OnDisappearing

$
0
0

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.


Viewing all articles
Browse latest Browse all 89864

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>