WebViewControl.LostFocus 事件

定义

WebViewControl 失去焦点时通知应用。 可由用户在 WebViewControl 内部/外部单击或通过编程焦点更改(例如,在不是 WebViewControl 的窗口上调用 SetFocus 的应用或 MoveFocus 方法调用)启动。

// 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) 

事件类型

Windows 要求

设备系列
Windows 10, version 1809 (在 10.0.17763.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v7.0 中引入)

示例

以下 C# 示例演示将 GotFocus 和 LostFocus 与 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

GotFocus 和 LostFocus 事件在 WebViewControl 接收或失去焦点时告知应用。 这可能是由于调用 MoveFocus,或用户单击 WebViewControl 内部/外部。

适用于