I am using Xamarin Forms with Prism. How do you navigate from the MasterDetail.Master to a ContentPage that is not part of the MasterDetail (that is, I don't want to just update the detail and continue to be part of the Master/Detail relationship)? The use case is like the Gmail app when you click on Settings from the Hamburger menu. It takes you out of the Master/Detail and you are now in a NavigationPage/ContentPage with a back button to get back to the MasterDetail page.
If you were not using Prism you could go to the Detail page and do a Navigation.PushAsync from there:
var mdp = Application.Current.MainPage as MasterDetailPage;
mdp.IsPresented = false;
await mdp.Detail.Navigation.PushAsync(new ContentPage2());
But I don't see how to do this using Prism navigation.
-Steve
Assuming your Application.Current.MainPage
is a MasterDetailPage
. Current Detail
in the MasterDetailPage
is NavigationPage(new ContentPage1())
.
In your ContentPage1
, you have 2 options to navigate to ContentPage2
:
Option 1: Show ContentPage2
in current navigation stack
You will be pushing ContentPage2
into the same Navigation stack of ContentPage1
. Back button in navigation bar will be added automatically.
// Call this code in ContentPage1
_navigationService.PushAsync("ContentPage2");
Option 2: Show ContentPage2
modally
You are presenting the page modally and in a completely new navigation stack. You will need to add Back button in the NavigationBar and handle the click event with your own code.
// Call this code in ContentPage1
_navigationService.PushAsync("NavigationPage/ContentPage2", null, true);