protected override bool OnBackButtonPressed() { try { if (App.nbrPopup > 0) { ContactPage.CloseAllPopup(); return(true); } else if (Accueil.nbrpopupA > 0) { nbrpopupA--; APropos.CloseAllPopup(); return(true); } else { // Do something if there are not any pages in the `PopupStack` var var2 = Accueil.buttonValeur; if (var2 != "accueil") { App.Current.MainPage = new Accueil(); Accueil.buttonValeur = "accueil"; return(true); } else { return(false); } } } catch (Exception ex) { Console.WriteLine(ex); } return(true); }