FrameworkElement.Loaded FrameworkElement.Loaded FrameworkElement.Loaded FrameworkElement.Loaded Event

定義

當項目已配置版面、呈現以及可以互動時發生。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 

備註

Loaded 通常的最後一個事件中引發的項目初始化順序。Loaded is usually the last event raised in an element initialization sequence. 它將會引發這個事件之後InitializedIt will always be raised after Initialized. 您是否選擇處理LoadedInitialized取決於您的需求。Whether you choose to handle Loaded or Initialized depends on your requirements. 如果您不需要讀取項目屬性,想要重設屬性,而且不需要任何版面配置的資訊,Initialized可能要採取更好的事件。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. 如果您需要的項目,可供使用,所有屬性,而且您會設定屬性,可能會重設配置,Loaded可能要採取更好的事件。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. (您可能需要檢查FrameworkPropertyMetadata上如果您不確定哪些屬性可能需要新的版面配置屬性的值傳遞,在變更時。)(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.)

如需序列的物件事件FrameworkElement,也針對幾個相關應用程式和項目類別,會看到物件存留期事件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. 直接路由的事件支援其他路由的事件的行為: 它們支援的可存取的處理常式集合,且可用來當做EventTrigger樣式。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.

LoadedUnloaded可能同時會引發因為使用者起始系統佈景主題變更控制項上。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. 因此Loaded無法假設發生只有當頁面是第一次載入透過 巡覽至頁面。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 - 委派Delegate RoutedEventHandler

適用於

另請參閱