Snowy Owl
Snowy Owl

Reputation: 161

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.

Upvotes: 0

Views: 365

Answers (1)

Mr Qian
Mr Qian

Reputation: 23808

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

Upvotes: 1

Related Questions