1
votes

I'm using Xamarin.Forms with Prism and a Master/Detail to create a "hamburger" menu. When the app runs, I navigate to NavigationService.NavigateAsync("MyMasterDetailPage/MyNavigationPage/MainPage");

I have items in the Master flyout menu for navigating to other pages. So I tap one and navigate to MyNavigationPage/SyncPage. At this point, if I hit the back button on Android, the app closes. Instead, I'd like to navigate back to the MainPage. I tried to hook into OnNavigatedFrom of the SyncPage to force navigation back to MainPage but the app is already closing by the time that event fires.

2

2 Answers

2
votes

Implement the INavigationPageOptions interface on MyNavigationPage and set ClearNavigationStackOnNavigation = false

1
votes

I implemented a solution similar to what Brian suggested but had to add a check to return true if it's the first time through in order to work correctly.