#615 – Standard Object Lifetime Events for FrameworkElement Objects

All objects in WPF that derive from FrameworkElement or FrameworkContentElement have three common events that fire as part of the element’s lifecycle.  Because these events are inherited from FrameworkElement and FrameworkContentElement, they are available for all controls, layout panels, Window objects and Page objects.

The three main object lifetime events are:

  • Initialized – Fires when an object has been created and all of its properties have been set.  Properties relating to layout have not yet been set
  • Loaded – Fires after the layout system has calculated all properties related to layout.  Data binding has occurred at this point, so controls should have their final property values.
  • Unloaded – Fires when element is removed from logical tree.  Will not fire if application is shutting down.