0

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.

Snowy Owl
  • 151
  • 1
  • 8
  • 1
    You can go with a non-`Window` shell or no shall at all, but there's no support (i.e. updates may break things unexpectedly): https://stackoverflow.com/questions/54333568/prism-7-using-prismapplication-createshell-with-a-non-window-control/54343953#54343953 – Haukinger Jan 24 '21 at 17:23
  • @SnowyOwl, does Haukinger's answer help you handle the issue? – Mr Qian Jan 25 '21 at 03:29
  • 1
    @PerryQian-MSFT yes, I chose another framework for my task. – Snowy Owl Jan 25 '21 at 10:12
  • @SnowyOwl, since Haukinger's answer does help to your issue, I have added his tip into an answer and you can consider accepting it to help other community members search and handle similar issues. And if you have an improvement , you could also add your workaround as answer to help improve the ticket. – Mr Qian Jan 26 '21 at 09:40

1 Answers1

1

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();
}
Mr Qian
  • 21,064
  • 1
  • 31
  • 41