ContentElement.OnLostFocus(RoutedEventArgs) ContentElement.OnLostFocus(RoutedEventArgs) ContentElement.OnLostFocus(RoutedEventArgs) ContentElement.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.

這在*方法執行的目的是要引發事件, 而這個相同的方法實作為內部叫用, 以便在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)*不同之處在于, 它只提供便利的方式來加入該事件的類別處理。This implementation differs from some other 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.

適用於