共用方式為


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類別將檔案重新導向至瀏覽器或其他應用程式。

適用於

另請參閱