[英]Xamarin forms: Multiple navigation patterns in the same app
Can we have multiple navigation patterns in a single app? 一个应用程序中可以有多个导航模式吗?
In my app.xaml page I added a function 在我的app.xaml页面中,我添加了一个功能
void SetUpNavigation()
{
var page = FreshPageModelResolver.ResolvePageModel<LaunchPageModel>();
var navPage = new FreshNavigationContainer(page);
MainPage = navPage;
}
But after a user signs in I want to use master detail page. 但是在用户登录后,我想使用主详细信息页面。 Is there a way to do that ?? 有没有办法做到这一点 ??
Yes. 是。 You just have to set the MainPage
of your app again. 您只需要再次设置应用程序的MainPage
。 In our projects, we use a helper class which have a method Restart
with following logic: 在我们的项目中,我们使用一个帮助程序类,该类具有以下方法的Restart
方法:
public static void Restart(View view, NavigationType navtype)
{
// Reset the mainpage depending on the navigation type
if (navtype == NavigationType.RestartWithMasterPage)
{
Application.Current.MainPage = new MasterPage(view);
}
else if (navtype == NavigationType.Restart)
{
Application.Current.MainPage = new NavigationPage(view);
}
else
{
// Just show the page
Application.Current.MainPage = view;
}
}
The NavigationType is an enum: NavigationType是一个枚举:
public enum NavigationType
{
Normal,
Restart,
RestartWithMasterPage
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.