WebView.UnviewableContentIdentified 事件

定义

WebView 尝试下载不受支持的文件时发生。

// Register
event_token UnviewableContentIdentified(TypedEventHandler<WebView, WebViewUnviewableContentIdentifiedEventArgs const&> const& handler) const;

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

// Revoke with event_revoker
WebView::UnviewableContentIdentified_revoker UnviewableContentIdentified(auto_revoke_t, TypedEventHandler<WebView, WebViewUnviewableContentIdentifiedEventArgs const&> const& handler) const;
public event TypedEventHandler<WebView,WebViewUnviewableContentIdentifiedEventArgs> UnviewableContentIdentified;
function onUnviewableContentIdentified(eventArgs) { /* Your code */ }
webView.addEventListener("unviewablecontentidentified", onUnviewableContentIdentified);
webView.removeEventListener("unviewablecontentidentified", onUnviewableContentIdentified);
- or -
webView.onunviewablecontentidentified = onUnviewableContentIdentified;
Public Custom Event UnviewableContentIdentified As TypedEventHandler(Of WebView, WebViewUnviewableContentIdentifiedEventArgs) 
<WebView UnviewableContentIdentified="eventhandler" />

事件类型

示例

下面的代码示例演示如何处理此事件以在 WebView 控件无法呈现目标内容时启动外部浏览器。 有关完整示例,请参阅 XAML WebView 控件示例

void webViewA_UnviewableContentIdentified(WebView sender, 
    WebViewUnviewableContentIdentifiedEventArgs args)
{
    appendLog(String.Format("Content for \"{0}\" cannot be loaded into webview. " +
        "Invoking the default launcher instead.\n", args.Uri.ToString()));

    // We turn around and hand the Uri to the 
    // system launcher to launch the default handler for it.
    Windows.Foundation.IAsyncOperation<bool> b = 
        Windows.System.Launcher.LaunchUriAsync(args.Uri);
    pageIsLoading = false;
}

注解

WebView 控件无法承载任意文件类型,但你可以处理此事件并使用 Launcher 类将文件重定向到浏览器或其他应用。

适用于

另请参阅