Element. 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
直接路由事件不遵循路由，它们只能在引发它们的同一元素内进行处理。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.
Loaded 由于 Unloaded 用户启动的系统主题更改，和可能都在控件上引发。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. 当属性定义的条件发生时，应用程序关闭 ShutdownMode 。Application shutdown occurs when the condition defined by the ShutdownMode property occurs. 如果将清理代码放在事件的处理程序中（例如 Unloaded 对于 Window 或 UserControl ），则可能不会按预期方式调用。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