c# - Prism 7. 将 PrismApplication.CreateShell() 与非 Window 控件一起使用

标签 c# wpf unity-container prism prism-7

我想从 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() 与非 Window 控件一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54333568/

相关文章:

c# - String[0] vs ToCharArray 然后 Char[0]

c# - 多个网站,单点登录设计

c# - 调用 GetOwner 时获取 InvalidOperationException

wpf - 更新 WPF ListBoxItem 而不使用 ListBox.Items.Refresh()?

asp.net-mvc - 将 Unity 与 Windows Azure 结合使用 : An attempt was made to access a socket in a way forbidden by its access permissions

C# Unity 依赖注入(inject),如何检索可枚举的实例?

javascript - 在javascript中读取cookie,由asp.net c#code制作

c# - WPF C# UIControl 像 iPhone 菜单图标一样摆动

c# - 如何从 WPF 表单中删除边框/控制框?

c# - 如何使用 Unity 解决静态类中的依赖关系?