UIElement.LostFocus Event


在此元素丢失逻辑焦点时发生。Occurs when this element loses logical focus.

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


如果有意通过某个方法调用强制失去了焦点,而前一个键盘焦点位于不同的范围内,则逻辑焦点将与键盘焦点不同。Logical focus differs from keyboard focus if focus is deliberately forced away by using a method call but the previous keyboard focus exists in a different scope. 在此方案中,键盘焦点仍保留在何处,而调用 Focus 方法的元素仍获得逻辑焦点。In this scenario, keyboard focus remains where it is, and the element where a Focus method is called still gets logical focus.

此事件的更精确解释是:当路由中某个元素的 IsFocused 属性的值从 true 改为 false时,将引发此事件。A more precise interpretation of this event is that it is raised when the value of the IsFocused property of an element in the route changes from true to false.

由于此事件使用冒泡路由,失去焦点的元素可能是一个子元素,而不是实际附加了事件处理程序的元素。Because this event uses bubbling routing, the element that loses focus might be a child element instead of the element where the event handler is actually attached. 检查事件数据中的 Source,以确定获得焦点的实际元素。Check the Source in the event data to determine the actual element that gained focus.

路由事件信息Routed Event Information

标识符字段Identifier field LostFocusEvent
路由策略Routing strategy 冒泡Bubbling
委托Delegate RoutedEventHandler
  • 没有相应的隧道事件。There is no corresponding tunneling event.

  • 重写 OnLostFocus 在派生类中实现此事件的类处理。Override OnLostFocus to implement class handling for this event in derived classes.

Applies to

See also