แก้ไข

แชร์ผ่าน


FrameworkElement.Initialized Event

Definition

Occurs when this FrameworkElement is initialized. This event coincides with cases where the value of the IsInitialized property changes from false (or undefined) to true.

public:
 event EventHandler ^ Initialized;
public event EventHandler Initialized;
member this.Initialized : EventHandler 
Public Custom Event Initialized As EventHandler 

Event Type

Remarks

This event will be raised whenever the EndInit or OnVisualParentChanged methods are called. Calls to either method could have come from application code, or through the Extensible Application Markup Language (XAML) processor behavior when a XAML page is processed.

Whether you choose to handle Loaded or Initialized depends on your requirements. If you do not need to read element properties, intend to reset properties, and do not need any layout information, Initialized might be the better event to act upon. If you need all properties of the element to be available, and you will be setting properties that are likely to reset the layout, Loaded might be the better event to act upon. Be careful of reentrancy if your handler resets any properties that are interpreted by the layout system to mean that a new layout pass is required. (You might need to check the FrameworkPropertyMetadata values on the property if you are unsure of which properties can require a new layout pass if they are changed.)

For more information about the sequence of object events for a FrameworkElement, and also for several related application and element classes, see Object Lifetime Events.

Applies to

See also