在 App.xaml.cs 或应用程序启动时在 ContentRegion(Prism) 中导航视图(登录)

阿尼什·库马尔

我正在尝试在应用程序启动时导航 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");

    }
杰罗姆·拉班

这似乎与PrismLib 中的这个问题有关,其中导航还不能直接从 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;

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

App.xaml.cs是在应用程序准备就绪之前必须完成的工作吗?

如何在app.xaml.cs文件中动态更改应用程序的主题

Windows 8从App.xaml.cs访问应用程序的页面方法

在应用程序启动时关闭导航抽屉

应用程序启动时无法关闭导航抽屉

在应用程序启动时登录用户

xamarin.forms 通知点击和来自 app.xaml.cs 的导航

从App.xaml.cs WPF按顺序启动两个窗口

如何在app.xaml.cs中启动消息框结果,但如何在另一个.xaml.cs页面上检索结果

(Xamarin Forms) 启动时应用程序崩溃(使用应用程序属性登录/注销)

如何在启动时删除App.xaml ResourceDictionary?

在App.xaml.cs中的Controltemplate中访问Textblock

App.xaml.cs ctor 在应调用 OnResume() 时调用

新窗口中App.xaml.cs中的引用对象

将参数从 app.xaml.cs 传递到 MainPage

App.xaml.cs中的Xamarin Forms Update值

在Windows Phone 8上从App.xaml.cs运行任务

当我添加应用程序 priv-app 手机无法启动时

如何从 App.xaml 而不是 App.xaml.cs 设置 MainPage?

C#是从App.xaml.cs访问WPF主窗口中的Static属性时导致此奇怪行为的原因

(与Redux反应导航向导)应用程序在启动时崩溃

如何根据用户是否登录来处理在应用程序启动时显示不同的视图控制器?

应用程序重新启动时保存视图状态android

在应用程序启动时,滚动到列表视图中的最后一个元素

MFC应用程序首次启动时如何禁用自动创建文档/视图

如何将XAML元素作为全局变量绑定到App.XAML.CS?

从视图(xaml.cs)调用视图模型方法

导航到ShellPage.xaml.cs中的页面导致异常

Windows Store Cordova App + WinJS:应用程序启动时崩溃并显示JavaScript运行时错误