UIElement.OnGotFocus(RoutedEventArgs) UIElement.OnGotFocus(RoutedEventArgs) UIElement.OnGotFocus(RoutedEventArgs) UIElement.OnGotFocus(RoutedEventArgs) Method


使用所提供的事件資料引發 GotFocus 路由事件。Raises the GotFocus routed event by using the event data provided.

 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)


RoutedEventArgs RoutedEventArgs RoutedEventArgs RoutedEventArgs

包含事件資料的 RoutedEventArgsA RoutedEventArgs that contains event data. 此事件資料必須包含 GotFocus 事件的識別項。This event data must contain the identifier for the GotFocus event.


此方法中,雖然是虛擬的沒有預設實作會引發事件。This method, although virtual, does have a default implementation that raises the event.

這在 * 方法實作用來引發事件,這個相同的方法實作是在內部叫用來引發事件時IsFocused屬性值變更。This On* method implementation is intended to raise the event, and this same method implementation is invoked internally to raise the event when the IsFocused property value changes. OnGotFocus實作不同於其他Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF)上 * 只提供便利的方式來加入類別處理該事件的實作。The OnGotFocus implementation differs from some other Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF) On* implementations, which only provide a convenient way to add class handling for that event.


除非您有不會引發焦點事件變成故意或不尋常的需要,請確定您的實作會呼叫基底實作。Unless you have a deliberate and unusual need to not raise the focus events, make sure that your implementation calls the base implementation. 否則,GotFocus通常將焦點設定至這個項目的一般使用者作業期間將不會引發事件。Otherwise, the GotFocus event is not raised during typical user operations that ordinarily set focus to this element. 如果您不想要您可設定焦點的項目,您可以防止項目設定成為可設定焦點FocusablefalseIf you do not intend your element to be focusable, you can prevent the element from being focusable by setting Focusable to false.