当用户使用freshMvvm方法FreshNavigationContainer
在方法FreshMasterDetailNavigationContainer
内登录时,我尝试从SuccessfulLogin
更改为PushNewNavigationServiceModal
但没有任何事情发生。
public void SuccessfulLogin()
{
App.IsLoggedIn = true;
var masterDetailNav = new FreshMasterDetailNavigationContainer();
masterDetailNav.Init("Menu");
masterDetailNav.AddPage<ProfilePageModel>("Profile", null);
CoreMethods.PushNewNavigationServiceModal(masterDetailNav);
}
修改: 我刚刚注意到使用此方法后,导航不再有效。
答案 0 :(得分:0)
您需要使用 CoreMethods.SwitchOutRootNavigation
首先设置您的NavigationStacks
public class NavigationStacks
{
public static string LoginNavigationStack = "LoginNavigationStack";
public static string MainAppStack = "MainAppStack";
}
在App.xaml.cs中定义导航
FreshNavigationContainer loginMain;
FreshMasterDetailNavigationContainer masterDetailNav;
var loginPage = FreshPageModelResolver.ResolvePageModel<UserLoginPageModel>();
loginMain = new FreshNavigationContainer(loginPage, NavigationStacks.LoginNavigationStack);
var masterDetailNav = new FreshMasterDetailNavigationContainer(NavigationStacks.MainAppStack);
masterDetailNav.Init("Menu");
masterDetailNav.AddPage<ProfilePageModel>("Profile", null);
然后在您的Login ViewModel
中public void SuccessfulLogin()
{
App.IsLoggedIn = true;
CoreMethods.SwitchOutRootNavigation(NavigationStacks.MainAppStack);
}