After reviewing MSDN, summarize the following UserControl's Load event:
When did the Q1:load event occur?
Occurs before the control becomes visible the first time.
The Load event occurs when a UserControl is created, so in some cases the Load event is called multiple times, such as when the UserControl is loaded, or when the operation is rebuilt (in the case of a call to the Recreatehandle method to re-create a handle to the control).
Q2: What do I need to pay attention to using the Load event?
- If UserControl is part of an MDI child form, the load event is triggered each time the subform is displayed.
- Because the load event may be called multiple times, the initialization code should be placed in the constructor instead of the Load event. You should also not apply the data Binding in the event handler for load.
Q3: What should I do in the Load event?
You can allocate the resources used by UserControl in the event handler for the load.
The Load event for the "WPF" UserControl