FreshMvvm PushNewNavigationServiceModal 不起作用



当用户使用 freshMvvm 方法登录方法SuccessfulLogin时,我正在尝试从FreshNavigationContainer更改为FreshMasterDetailNavigationContainer PushNewNavigationServiceModal但没有任何反应。

    public void SuccessfulLogin()
    {
        App.IsLoggedIn = true;
        var masterDetailNav = new FreshMasterDetailNavigationContainer();
        masterDetailNav.Init("Menu");
        masterDetailNav.AddPage<ProfilePageModel>("Profile", null);
        CoreMethods.PushNewNavigationServiceModal(masterDetailNav);
    }

编辑 :我刚刚注意到使用此方法后导航不再起作用。

你需要使用 CoreMethods.SwitchOutRootNavigation

首先设置您的导航堆栈

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);

然后在您的登录视图中模型

public void SuccessfulLogin()
{
    App.IsLoggedIn = true;
    CoreMethods.SwitchOutRootNavigation(NavigationStacks.MainAppStack);
}

相关内容

  • 没有找到相关文章

最新更新