ContentElement.OnGotFocus(RoutedEventArgs) 方法

定義

使用所提供的事件資料引發 GotFocus 路由事件。

protected:
 virtual void OnGotFocus(System::Windows::RoutedEventArgs ^ e);
protected virtual void OnGotFocus (System.Windows.RoutedEventArgs e);
abstract member OnGotFocus : System.Windows.RoutedEventArgs -> unit
override this.OnGotFocus : System.Windows.RoutedEventArgs -> unit
Protected Overridable Sub OnGotFocus (e As RoutedEventArgs)

參數

e
RoutedEventArgs

包含事件資料的 RoutedEventArgs。 此事件資料必須包含 GotFocus 事件的識別項。

備註

這個方法雖然是虛擬的,但是有引發事件的預設實作。

這個 On* 方法實作的目的是要引發 事件,而這個相同的方法實作會在內部叫用,以在屬性值變更時 IsFocused 引發事件。 此 OnGotFocus 實作與其他Windows Presentation Foundation (WPF) On* 實作不同,這只會提供方便的方式來新增該事件的類別處理。

繼承者的注意事項

除非您有刻意且不尋常的需要引發焦點事件,否則請確定您的實作會呼叫基底實作。 否則,在 GotFocus 一般使用者作業期間不會引發事件,這些作業通常會將焦點設定為這個專案。 如果您不想要讓元素成為可焦點,您可以將 設定 Focusablefalse 為 ,以防止元素成為可焦點。 請注意,根據預設 Focusable ,無法將焦點放在一起,因此可能不需要刻意設定 Focusable

適用於

另請參閱