Udostępnij za pośrednictwem


WebViewControl.LostFocus Event

Definition

Informs your app when the WebViewControl loses focus. May be initiated by the user clicking inside/outside the WebViewControl or by a programmatic focus change, such as the app calling SetFocus on a window that is not the WebViewControl or a MoveFocus method call.

// Register
event_token LostFocus(TypedEventHandler<WebViewControl, IInspectable const&> const& handler) const;

// Revoke with event_token
void LostFocus(event_token const* cookie) const;

// Revoke with event_revoker
WebViewControl::LostFocus_revoker LostFocus(auto_revoke_t, TypedEventHandler<WebViewControl, IInspectable const&> const& handler) const;
public event TypedEventHandler<WebViewControl,object> LostFocus;
function onLostFocus(eventArgs) { /* Your code */ }
webViewControl.addEventListener("lostfocus", onLostFocus);
webViewControl.removeEventListener("lostfocus", onLostFocus);
- or -
webViewControl.onlostfocus = onLostFocus;
Public Custom Event LostFocus As TypedEventHandler(Of WebViewControl, Object) 

Event Type

Windows requirements

Device family
Windows 10, version 1809 (introduced in 10.0.17763.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v7.0)

Examples

The following C# sample demonstrates an event using GotFocus and LostFocus with the WebViewControl:

WebViewControl webViewControl; 

void WebViewControlGotFocus(WebViewControl sender, IInspectable args) 
{ 
    AddFocusHighlightToElement(sender); 
} 

void WebViewControlLostFocus(WebViewControl sender, IInspectable args) 
{ 
    RemoveFocusHighlightFromElement(sender); 
} 

webViewControl.GotFocus += WebViewControlGotFocus; 
webViewControl.LostFocus += WebViewControlLostFocus

The GotFocus and LostFocus event tell the app when WebViewControl receives or loses focus. This could be due to a call to MoveFocus, or due to the user clicking inside/outside the WebViewControl.

Applies to