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

User confirmation for exiting Application

$
0
0

Hello, I Am trying to get a user confirmation box when user clicks back button from my app for asking him whether he wants to exit or not and with selection of Yes, App should exit. I am using code mentions bellow but it is not working properly as with the selection of Yes for exiting the App, App does not exit and if I click back button once again then it exits. Can anyone help me with this

public bool CloseApp = true;
    protected override bool OnBackButtonPressed()
    {
        Device.BeginInvokeOnMainThread(async () =>
        {                  
                var result = await this.DisplayAlert("Attention!", "Do you really want to exit the application?", "Yes", "No");
                if (result)
                {
                CloseApp = false;

                }

        });

        return CloseApp;

    }

Viewing all articles
Browse latest Browse all 77050

Trending Articles



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