【问题标题】:Prism 7. Using PrismApplication.CreateShell() with a non Window controlPrism 7. 将 PrismApplication.CreateShell() 与非窗口控件一起使用
【发布时间】:2019-01-23 18:33:10
【问题描述】:

我想从 6.3 更新到 7。

我似乎遇到了障碍。

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

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

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

【问题讨论】:

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


    【解决方案1】:

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

    引导程序仍然存在。它被标记为已弃用,可能会在未来的版本中消失,但只要它存在,您就可以使用它。 至少,直到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();
    }
    

    【讨论】:

    • 烦人的问题已被锁定,因为另一个用例是从一开始就在系统托盘中运行的应用程序,因此没有启动窗口!
    猜你喜欢
    • 1970-01-01
    • 2011-02-06
    • 1970-01-01
    • 1970-01-01
    • 2022-03-28
    • 2015-07-29
    • 2017-06-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多