gpt4 book ai didi

c# - Prism 7. 在非窗口控件中使用 PrismApplication.CreateShell()

转载 作者:行者123 更新时间:2023-11-30 22:56:36 29 4
gpt4 key购买 nike

我想从 6.3 更新到 7。

我好像遇到了障碍。

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

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

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

最佳答案

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

Bootstrap 仍然存在。它被标记为已弃用,可能会在未来的版本中消失,但只要它存在,您就可以使用它。 至少,直到 PrismApplicationBase 的问题得到解决。您应该在 github 上创建一个问题为此。

编辑:

问题已经提出,不会被修复 ( 1413 )。

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

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();
}

关于c# - Prism 7. 在非窗口控件中使用 PrismApplication.CreateShell(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54333568/

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