如何在没有 Application class 或不覆盖它的情况下在项目中正确使用 WPF Prism?

How to use WPF Prism correctly in a project without Application class or without overriding it?

是否可以在不覆盖应用程序的情况下使用 Prism class?例如,在为 Visual Studio 开发扩展时。我还没有找到如何做到这一点的例子。

答案是。您可以使用相关代码,您仍然可以使用它们:

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