ContentElement.GotFocus ContentElement.GotFocus ContentElement.GotFocus ContentElement.GotFocus Event

定義

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

public:
 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屬性值從false變更為true時, 就會引發此事件。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 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.

適用於

另請參閱