UIElement.OnLostFocus(RoutedEventArgs) 方法

定義

使用所提供的事件資料引發 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

包含事件資料的 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) ,它們只提供一個方便的方法來新增該事件的類別處理。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 falseIf you do not intend your element to be focusable, you can prevent the element from being focusable by setting Focusable to false.

適用於