Hello,
where I can display an alert to ask him,if sure he wants to exit.
If you want to detect the back icon clicked (triangle button), you can override OnBackButtonPressed
method and push an alert. If user click the yes, we can execute Application.Current.Quit();
to finish application, if no, application still in the foreground and alert disappear.
protected override bool OnBackButtonPressed()
{
Task<bool> answer = DisplayAlert("Question?", "Do you want to exit?", "Yes", "No");
answer.ContinueWith(task =>
{
if (task.Result)
{
Application.Current.Quit();
}
});
return true;
}
Best Regards,
Leon Lu
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.