Home > OS >  How to create Module Catalog and Reigster Types without opening the MainWindow in Prism
How to create Module Catalog and Reigster Types without opening the MainWindow in Prism

Time:09-16

I'm writing a dll for another application and I want to implement my own button in this application which would open a dll which, in turn, would open WPF form.

The question is, when application is being open, I want to do some things for a WPF application which user will open later. For instance, I want to create Module Catalog. In other words, I want to initialize WPF application without opening the Main Window. Due to the opening WPF from another dll, I create an instance of my Application:

    App app = new App();

My App class basically looks like this:

     public partial class App : PrismApplication
     {
        protected override Window CreateShell()
        {
            return Container.Resolve<MainWindow>();
        }
    
        protected override void RegisterTypes(IContainerRegistry containerRegistry)
        {
    
        }
    
        protected override IModuleCatalog CreateModuleCatalog()
        {
           
        }
    }

So I want CreateModuleCatalog and RegisterTypes methods to be completed, but don't want to show the MainWindow from CreateShell method right now.

Could anyoune tell how can I handle this problem?

CodePudding user response:

If you return null from CreateShell(), there is no window to be displayed.

You can also override OnInitialized(). It's where Prism calls MainWindow?.Show() by default.

Having that said, it's a good practice to always display some kind of splash window as soon as possible.

  • Related