UIElement.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 ,以防止元素成為焦點。

適用於

另請參閱