WPF Prism框架下先登录窗体再打开主窗体

        如果直接Container.Resolve();这样可以实现先打开登录窗体,然后登录成功的话打开主窗体,关闭登录窗体,会发现问题:
The region manager does not contain the contentFrame region,这个regionManager.RequestNavigate无法工作,不能正常加载,

解决方案:

重写OnInitialized方法,代码如下:

        protected override Window CreateShell()
        {
            return Container.Resolve();
        }

        protected override void OnInitialized()
        {
            var dialog = Container.Resolve();

            dialog.ShowDialog("Login", callback =>
            {
                if (callback.Result != ButtonResult.OK)
                {
                    Environment.Exit(0);
                    return;
                }
            });
            base.OnInitialized();
        }

你可能感兴趣的:(wpf,c#,开发语言)