I have a xamarin form page where a user can update some data in a form. I need to intercept the Navigation Bar Back Button Clicked to warn the user if some data have not been saved.How to do it?
I'm able to intercept the hardware Bar Back Button Clicked in Android using the Android.MainActivity.OnBackPressed()
, but that event is raised only on hardware Bar Back Button Clicked, not on Navigation Bar Back Button Clicked.
I tried also to override Xamarin.Forms.NavigationPageOnBackButtonPressed()
but it doesn't work. Why?
Any one have already solved that issue?
I also tried by overriding OnDisappear()
, there are two problems:
- The page has already visually disappeared so the "Are you sure?" dialog appears over the previous page.
- Cannot cancel the back action.
So, is it possible to intercept the navigation bar back button press?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…