I am looking for a diagram that will serve as a reference to show the order of events and overrides that get called for WPF custom controls that derive from common classes such as FrameworkElement, UIElement, Control, ContentControl, Decorator, etc.
I am particularly interested in the events and overrides dealing with the process of the control becoming visible and ready to interact with. In other words, I'm not as interested in this diagram showing the events that could deal with the user interacting with the control after it is ready to be interacted with, such as things like MouseLeftButtonDown.
What I am looking for is something like this diagram (diagrams like these explain the lifecyle of a WPF window or application) but for custom controls.
I've also seen this page, which, in my opinion makes it seem too simplistic. That page seems to basically say that there's mostly just the Initialized, Loaded, and Unloaded events. To illustrate, a few of the general events/overrides I've needed to make use of in custom controls include:
- Constructor
LoadedUnLoadedIsVisibleChangedOnApplyTemplate
Along with slightly more specialized overrides like Popup's OnOpened and Expander's OnExpanded, etc.
The problem I am having is that I forget when I can do things like VisualStateManager.GoToState(...) (OnApplyTemplate is the first real chance I believe). And I also keep discovering events that I need to make use of, such as the IsVisibleChanged (this event proved necessary when I needed a control to do a "reload/refresh" state change when the user returns to the Tab that contains my control). So I keep wondering are there yet other such events/overrides that I should really be paying attention to for a custom control? This is where a diagram that shows these things in relation to each other will help.
Considering these types of events/overrides, this Silverlight chart is pretty close to what I'm looking for, but for WPF. Some of the commenters on that post say that WPF's events/overrides are different than Silverlight's. If so, can you please point me to a similar diagram?
To further illustrate the need for such a diagram, consider the following sequence of events that I just witnessed on a custom control that derives from ContentControl:
- App started up. (My custom control is in a different tab than the intial tab.)
Initializedevent callback calledLoadedevent callback called- (I click on the tab that contains my custom control)
IsVisibleChangedevent callback calledOnApplyTemplateoverride calledLoadedevent callback calledLoadedevent callback called againLoadedevent callback called third time in a row- (Control is now fully visible and ready to interact with)