What is the firing order of WPF events?

Instantiating a WPF Window

When you instantiate a WPF Window, each element is initialized from the bottom up. Deeply nested UI elements are initialized first. Here is the sequence of events:

  1. The user interface element is instantiated

  2. The element's BeginInit() method is invoked

  3. The XAML parser sets all element properties and adds any content

  4. The element's EndInit() method is invoked

  5. The element's Initialized event fires and its IsInitialized property is set to true

  6. After initialization is complete for all elements and it's fired for the Window, the Loaded event is fired in reverse order--from the containing Window down to the most deeply nested elements and the IsLoaded property is set to true. When Loaded has fired for all elements, the window becomes visible and its elements are rendered.

  7. The Window's ContentRendered event fires after the window has been rendered, visibile, and ready for input

  8. The Window's SourceInitialized event fires when the HwndSource property of the window is acquired but before it's made visible

  9. The Window's Activated event fires

Closing a WPF Window

Here is the sequence of events when closing a WPF Window:

  1. The Closing event fires. You can prevent the Window from closing by setting the CancelEventArgs.Cancel property to true

  2. The Deactivated event fires

  3. The Closed event fires after the Window is closed, but you can still access form elements

  4. The Unloaded event fires

Activating and Deactivating Windows

The Deactivated event fires when switching away from the window to another window or another application.

The Activated event not only occurs when the form is first instantiated, but also when the user switches to this window from another window or from another application.


© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 04/26/18
Comment or report problem with topic