#612 – Application Event Sequence for Page-Based Applications

When you create a page-based application in WPF, you use a NavigationWindow as the main window, which in turn hosts one or more Page objects.  (If you set the StartupUri property of the Application to point to a Page, a NavigationWindow will be created automatically).

The sequence of Application events that fire for a page-based application are listed below.

When you start the application (assuming that a Page is specified as the StartupUri):

  • Startup
  • Navigating
  • Navigated
  • LoadCompleted
  • Activated

When you shut the application down normally:

  • Deactivated
  • Exit

When you navigate to a new Page:

  • Navigating
  • NavigationProgress  (1 or more times)
  • Navigated
  • LoadCompleted

User is logging out of or shutting down Windows:

  • Deactivated
  • SessionEnding

Application gains focus:

  • Activated

Application loses focus:

  • Deactivated

#610 – Application Event Sequence

The sequence of events for an application’s main Application object that are fired are as follows (all events listed in the order that they fire):

When you start the application:

  • Startup
  • Activated

When you shut the application down normally (i.e. close main window):

  • Deactivated
  • Exit

If the application experiences an unhandled exception:

  • DispatcherUnhandledException

If user is logging out of or shutting down Windows:

  • Deactivated
  • SessionEnding

Application gets focus:

  • Activated

Application loses focus:

  • Deactivated