I am stuck at one point in Xamarin.Forms application
On Back button press simply I want to ask user to confirm whether he really wants to exit or not, "OnBackButtonPressed" I want to show Alert dialog and proceed as user response.
But "OnBackButtonPressed" is not Async I cannot write await DisplayAlert... Please direct me how should i implement this feature?
I am using ContentPage as my root Page of NavigationPage
public class frmHome : ContentPage
Here is the code :
protected override bool OnBackButtonPressed()
{
var result = await this.DisplayAlert("Alert!", "Do you really want to exit?", "Yes", "No");
if (result)
{
//user wants to exit
//Terminate application
}
else
{
//Dont do anything
}
}