Prism 7. Using PrismApplication.CreateShell() with a non Window control

一世执手 提交于 2021-01-27 20:55:19

问题


I would like to update from 6.3 to 7.

I seem to have hit a road block.

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.

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

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?


回答1:


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

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.

Edit:

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


来源:https://stackoverflow.com/questions/54333568/prism-7-using-prismapplication-createshell-with-a-non-window-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!