Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Event upon initialization complete in WPF/Prism app

Tags:

wpf

prism

In non-Prism WPF app, if I want to run code after initialization (e.g. execute the task specified by command-line argument), I can do it in Loaded event of the main window. However with Prism, the modules are initialized after main window is displayed, that is, IModule.Initialize() is called after Bootstrapper.CreateShell() and Bootstrapper.InitializeShell(). In this case which event/override should I use?

like image 442
NS.X. Avatar asked Nov 30 '25 22:11

NS.X.


1 Answers

The last thing called by UnityBootstrapper.Run(bool runWithDefaultConfiguration) is InitializeModules() (well apart from a call to Logger.Log). So overide Run(...).

class Bootstrapper : UnityBootstrapper
{
    ...
    public override void Run(bool runWithDefaultConfiguration)
    {
        base.Run(runWithDefaultConfiguration);

        // modules (and everything else) have been initialized when you get here
    }
}
like image 50
Phil Avatar answered Dec 03 '25 14:12

Phil



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!