UIElement.OnLostFocus(RoutedEventArgs) UIElement.OnLostFocus(RoutedEventArgs) UIElement.OnLostFocus(RoutedEventArgs) UIElement.OnLostFocus(RoutedEventArgs) Method

定义

使用提供的事件数据引发 LostFocus 路由事件。Raises the LostFocus routed event by using the event data that is provided.

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

参数

e
RoutedEventArgs RoutedEventArgs RoutedEventArgs RoutedEventArgs

包含事件数据的 RoutedEventArgsA RoutedEventArgs that contains event data. 此事件数据必须包含 LostFocus 事件的标识符。This event data must contain the identifier for the LostFocus event.

注解

虽然虚拟, 但这种方法具有引发事件的默认实现。This method, although virtual, does have a default implementation that raises the event.

此 On * 方法实现旨在引发事件, 并在内部调用此相同的方法实现, 以在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. 此实现与其他Windows Presentation Foundation (WPF)Windows Presentation Foundation (WPF)一些 On * 实现不同, 后者仅提供一种方便的方法来为该事件添加类处理。This 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. 否则, 在LostFocus通常将焦点设置到此元素的典型用户操作期间, 不会引发事件。Otherwise, the LostFocus event is not raised during typical user operations that ordinarily set focus to this element. 如果不想让元素获得可设定焦点的元素, 则可以通过将设置Focusable为来false防止元素获得焦点。If you do not intend your element to be focusable, you can prevent the element from being focusable by setting Focusable to false.

适用于