Shimmy Weitzhandler
Shimmy Weitzhandler

Reputation: 104711

System.Windows.Application.OnLoadCompleted never reached

Hello I am trying to handle the Application.LoadCompleted event but it's never triggered.

Instead I am seeing the MainWindow.

I tried attaching the event by either xaml, or directly by overriding the OnLoadCompleted method of the Application class.

Upvotes: 3

Views: 3243

Answers (3)

Simon_Weaver
Simon_Weaver

Reputation: 145890

It's possible you're using the wrong event for what you want.

If you are just trying to initialize your application - perhaps to set up global messaging handlers or you can use OnStartup.

public partial class App : Application
{
    static App()
    {
        DispatcherHelper.Initialize();
    }

    protected override void OnStartup(StartupEventArgs e)
    {
        InitializeMVVM();
    }
}

Upvotes: 3

Kent Boogaart
Kent Boogaart

Reputation: 178630

It could be simply that you're attaching the event too late. i.e. after the loaded event has already fired. Show us the code...

Upvotes: 0

Henk Holterman
Henk Holterman

Reputation: 273179

Does your MainWindow contain a Frame?

If you read the text for the event (not the On... method), it says

Occurs when content that was navigated to by a navigator in the application has been loaded

I just tested on a Form with a Frame and the event fires just fine.

Upvotes: 5

Related Questions