3

在非 Prism WPF 应用程序中,如果我想在初始化后运行代码(例如执行命令行参数指定的任务),我可以Loaded在主窗口的事件中执行。但是对于 Prism,模块是在显示主窗口后初始化的,即在和IModule.Initialize()之后调用。在这种情况下,我应该使用哪个事件/覆盖?Bootstrapper.CreateShell()Bootstrapper.InitializeShell()

4

1 回答 1

5

最后调用的UnityBootstrapper.Run(bool runWithDefaultConfiguration)InitializeModules()(除了调用 Logger.Log)。所以覆盖 Run(...)。

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

        // modules (and everything else) have been initialized when you get here
    }
}
于 2012-05-05T22:15:00.063 回答