gpt4 book ai didi

xamarin - FreshMvvm PushNewNavigationServiceModal不起作用

转载 作者:行者123 更新时间:2023-12-03 10:43:07 24 4
gpt4 key购买 nike

当用户通过使用freshMvvm方法FreshNavigationContainer在方法FreshMasterDetailNavigationContainer中登录时,我试图将SuccessfulLogin更改为PushNewNavigationServiceModal,但没有任何 react 。

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

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

最佳答案

您需要使用 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);

然后在您的登录ViewModel中
public void SuccessfulLogin()
{
App.IsLoggedIn = true;
CoreMethods.SwitchOutRootNavigation(NavigationStacks.MainAppStack);
}

关于xamarin - FreshMvvm PushNewNavigationServiceModal不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44607085/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com