在App.xaml.cs的ContentRegion(Prism)中导航一个View(Login)或在应用程序Launch上导航一个View(Login)。

问题描述 投票:0回答:1

我正试图在Prism ContentRegion中导航一个登录视图以启动应用程序。

protected override void RegisterTypes(IContainerRegistry containerRegistry)
    {
        containerRegistry.RegisterForNavigation<Login>("Login");
    }
    protected override void OnInitialized()
    {
        base.OnInitialized();
        var regionManager = Container.Resolve<IRegionManager>();
        regionManager.RequestNavigate("ContentRegion", "Login");

    }
prism uno-platform
1个回答
0
投票

这似乎与以下问题有关 对这个问题 中,导航还不能直接从OnInitialized中完成。

作为一个变通方法,你可以做两件事,直到这个问题得到解决。

  • 使用RegisterViewWithRegion
  • 或者只导航一次 Window 已被激活。
void Navigate(object sender, object args)
{
    regionManager.RequestNavigate("ContentRegion", "Login");

    Windows.UI.Xaml.Window.Current.Activated -= Navigate;
}

Windows.UI.Xaml.Window.Current.Activated += Navigate;
© www.soinside.com 2019 - 2024. All rights reserved.