#613 – Window Event Sequence

The full sequence of events fired for a Window object are as follows.

On application startup, if the Window is the application’s main window.  (Application events are also shown in the correct sequence).

  • Application.Startup
  • Window.Initialized
  • Window.IsVisibleChanged
  • Window.SizeChanged
  • Window.LayoutUpdated
  • Window.SourceInitialized
  • Application.Activated
  • Window.Activated
  • Window.PreviewGotKeyboardFocus
  • Window.IsKeyboardFocusWithinChanged
  • Window.IsKeyboardFocusedChanged
  • Window.GotKeyboardFocus
  • Window.LayoutUpdated
  • Window.Loaded
  • Window.ContentRendered

On normal application shutdown, the event sequence is:

  • Window.Closing
  • Window.IsVisibleChanged
  • Window.Deactivated
  • Application.Deactivated
  • Window.IsKeyboardFocusWithinChanged
  • Window.IsKeyboardFocusedChanged
  • Window.LostKeyboardFocus
  • Window.Closed
  • Application.Exit

When application/window loses focus (user switches to another application):

  • Window.Deactivated
  • Application.Deactivated
  • Window.IsKeyboardFocusWithinChanged
  • Window.IsKeyboardFocusedChanged
  • Window.LostKeyboardFocus

When application/window gains focus (user switches back to application):

  • Application.Activated
  • Window.Activated
  • Window.PreviewGotKeyboardFocus
  • Window.IsKeyboardFocusWithinChanged
  • Window.IsKeyboardFocusChanged
  • Window.GotKeyboardFocus
Advertisement

#41 – Window Events at Startup and Shutdown

At application startup, the Window events that are fired (in order) for the main window are:

  • Initialized – Main window is being created
  • IsVisibleChanged IsVisible property set to true
  • SizeChanged – Size property set to size of window
  • LayoutUpdated – Window layout changes
  • SourceInitialized – Window is attached to Win32 window handle
  • Activated – Window becomes foreground window
  • PreviewGotKeyboardFocus – Window getting focus
  • IsKeyboardFocusWithinChanged IsKeyboardFocusWithin property set to true
  • IsKeyboardFocusedChanged IsKeyboardFocused property set to true
  • GotKeyboardFocus – Window now has keyboard focus
  • LayoutUpdated – Window layout changes
  • Loaded – Window is now laid out, fully rendered
  • ContentRendered – All window content has been rendered

At application shutdown, the Window events fired (in order) are:

  • Closing – Window is going to close
  • IsVisibleChanged IsVisible property set to false
  • Deactivated – Window becomes background window
  • IsKeyboardFocusWithinChanged IsKeyboardFocusWithin property set to false
  • IsKeyboardFocusedChanged IsKeyboardFocused property set to false
  • LostKeyboardFocus – Window no longer has keyboard focus
  • Closed – Window is closing