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


當項目已配置版面、呈現以及可以互動時發生。Occurs when the element is laid out, rendered, and ready for interaction.

 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. 它一律會在之後Initialized引發。It 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