您如何使用棱镜从主细节到内容页面进行Xamarin表单,而无需大师详细信息



我正在使用带有棱镜的Xamarin形式。您如何从MasterDetail.master到不属于MasterDetail的一部分的内容页面(也就是说,我不想更新细节并继续成为主/详细信息关系的一部分)?当您从汉堡菜单中单击设置时,用例就像Gmail应用程序一样。它将带您离开主/细节,现在您正在带有后背按钮的导航page/contentpage中,以返回MasterDetail页面。

如果您不使用Prism,则可以转到详细页面并进行avarigation.pushasync:

var mdp = Application.Current.MainPage as MasterDetailPage;
mdp.IsPresented = false;
await mdp.Detail.Navigation.PushAsync(new ContentPage2());

,但我看不到如何使用Prism导航。

-steve

假设您的Application.Current.MainPageMasterDetailPageMasterDetailPage中的当前DetailNavigationPage(new ContentPage1())

在您的ContentPage1中,您有2个选项可以导航到ContentPage2

选项1:在当前导航堆栈中显示ContentPage2

您将将ContentPage2推入ContentPage1的同一导航堆栈中。导航栏中的后按钮将自动添加。

// Call this code in ContentPage1
_navigationService.PushAsync("ContentPage2");

选项2: show ContentPage2 modally

您正在将页面形式上介绍,并在全新的导航堆栈中介绍。您将需要在NavigationBar中添加返回按钮,并使用自己的代码处理点击事件。

// Call this code in ContentPage1
_navigationService.PushAsync("NavigationPage/ContentPage2", null, true);

最新更新