Prism 7. 将 PrismApplication.CreateShell() 与非 Window 控件一起使用 [英] Prism 7. Using PrismApplication.CreateShell() with a non Window control

查看:62
本文介绍了Prism 7. 将 PrismApplication.CreateShell() 与非 Window 控件一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从 6.3 更新到 7.

I would like to update from 6.3 to 7.

我似乎遇到了障碍.

在 App.xaml 中使用 PrismApplication 类时,CreateShell 期望返回类型为 Window,而不是之前需要 DependencyObject 的 BootStrapper.

When using the PrismApplication class in the App.xaml, CreateShell expects a return type of Window instead of the previous BootStrapper which wanted a DependencyObject.

我的 MainShell 是一个经过修改的 Telerik RadWindow,它本身就是一个经过修改的 System.Windows.Controls.HeaderedContentControl 并且无法转换为 Window.

My MainShell is a modified Telerik RadWindow which itself is a modified System.Windows.Controls.HeaderedContentControl and casting to Window is not possible.

有没有办法解决这个问题,以便我可以使用 PrismApplication 对象,还是必须像以前一样回滚并使用 BootStrapper?

Is there a way around this so I can use the PrismApplication object or do I have to roll back and use the BootStrapper like before?

推荐答案

我是否必须像以前一样回滚并使用 BootStrapper?

do I have to roll back and use the BootStrapper like before?

引导程序仍然存在.它被标记为已弃用并且可能会在未来版本中消失,但只要它存在,您就可以使用它.至少,直到PrismApplicationBase 的问题被修复.为此,您应该在 github 上创建一个问题.

The bootstrapper is still there. It is marked as deprecated and might go away in a future version, but as long as it's there, you can use it. At least, until the problem with PrismApplicationBase is fixed. You should create an issue on github for that.

这个问题已经被提出了,它不会被修复(1413).

The issue has already been brought up and it won't be fixed (1413).

我将从问题中复制建议的解决方法以供参考:

I'll copy the proposed workaround from the issue for reference:

protected override Window CreateShell()
{
    return null;
}

protected override void OnInitialized()
{
    var shellWindow = Container.Resolve<ShellWindow>();
    shellWindow.Show();
    MainWindow = shellWindow.ParentOfType<Window>();

    // there lines was not executed because of null Shell - so must duplicate here. Originally called from PrismApplicationBase.Initialize
    RegionManager.SetRegionManager(MainWindow, Container.Resolve<IRegionManager>());
    RegionManager.UpdateRegions();
    InitializeModules();

    base.OnInitialized();
}

这篇关于Prism 7. 将 PrismApplication.CreateShell() 与非 Window 控件一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆