Search code examples
c#wpfprismvisual-studio-extensions

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


Can Prism be used without overriding the Application class? For example, when developing an extension for Visual Studio. I have not found examples of how this can be done.


Solution

  • The answer is here. You can use the related code and you can still use them:

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