UIElement.GotFocus UIElement.GotFocus UIElement.GotFocus UIElement.GotFocus Event


此元素取得邏輯焦點時發生。Occurs when this element gets logical focus.

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


如果使用的方法呼叫刻意強制焦點,但存在於不同範圍的上一個鍵盤焦點,則邏輯焦點與鍵盤焦點。Logical focus differs from keyboard focus if focus is deliberately forced 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路由的項目屬性變更時,從falsetrueA more precise interpretation of this event is that it is raised when the value of the IsFocused property of an element in the route is changed from false to true.

此事件會使用事件反昇的路由,因為接收焦點的項目可能的子項目,而非項目實際附加事件處理常式。Because this event uses bubbling routing, the element that receives 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 GotFocusEvent
路由策略Routing strategy 事件反昇Bubbling
Delegate - 委派Delegate RoutedEventHandler
  • 沒有任何對應的通道事件。There is no corresponding tunneling event.

  • 覆寫OnGotFocus實作在衍生類別中這個事件的類別處理。Override OnGotFocus to implement class handling for this event in derived classes.