FrameworkElement.Unloaded 事件

定義

當項目從已載入項目的項目樹狀結構中移除時發生。Occurs when the element is removed from within an element tree of loaded elements.

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

事件類型

RoutedEventHandler

備註

直接路由事件不會遵循路由,只會在引發它們的相同元素內處理。Direct routed events do not follow a route, they are only handled within the same element on which they are raised. 直接路由事件支援其他路由事件行為:它們支援可存取的處理常式集合,而且可以當做樣式中的來使用 EventTriggerDirect 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. 因此 Unloaded ,無法假設只有在離開頁面的導覽上才會發生。Therefore Unloaded cannot be assumed to occur only on navigation away from the page.

請注意,在 Unloaded 應用程式開始關機之後,不會引發事件。Note that the Unloaded event is not raised after an application begins shutting down. 當屬性定義的條件發生時,就會發生應用程式關閉 ShutdownModeApplication shutdown occurs when the condition defined by the ShutdownMode property occurs. 如果您將清除程式碼放在事件的處理常式中( Unloaded 例如針對 WindowUserControl ),它可能不會如預期般呼叫。If you place cleanup code within a handler for the Unloaded event, such as for a Window or a UserControl, it may not be called as expected.

路由事件資訊Routed Event Information

識別碼欄位Identifier field UnloadedEvent
路由策略Routing strategy 直接Direct
代理人Delegate RoutedEventHandler

適用於

另請參閱