Редагувати

Поділитися через


FrameworkElement.Loaded Event

Definition

Occurs when the element is laid out, rendered, and ready for interaction.

public:
 event System::Windows::RoutedEventHandler ^ Loaded;
public event System.Windows.RoutedEventHandler Loaded;
member this.Loaded : System.Windows.RoutedEventHandler 
Public Custom Event Loaded As RoutedEventHandler 

Event Type

Remarks

Loaded is usually the last event raised in an element initialization sequence. It will always be raised after Initialized. 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.

Direct routed events do not follow a route, they are only handled within the same element on which they are raised. Direct routed events do support other routed event behavior: they support an accessible handlers collection, and can be used as an EventTrigger in a style.

Loaded and Unloaded might both be raised on controls as a result of user-initiated system theme changes. A theme change causes an invalidation of the control template and the contained visual tree, which in turn causes the entire control to unload and reload. Therefore Loaded cannot be assumed to occur only when a page is first loaded through navigation to the page.

Routed Event Information

Identifier field LoadedEvent
Routing strategy Direct
Delegate RoutedEventHandler

Applies to

See also