.net 如何将文档加载到WebView?

.net 如何将文档加载到WebView?,.net,webview,windows-runtime,winrt-xaml,webclient,.net,Webview,Windows Runtime,Winrt Xaml,Webclient,我想这样做 Uri targetUri = new Uri(Address.Text); WebView1.Navigate(targetUri); string content = WebView1.GetDocument(); //How can I get the document loaded from the target Uri? 我看过MSDN中的API,但没有看到任何值得注意的内容 我想我可以连接到FrameNavigationStarting,捕获Uri并通过WebC

我想这样做

Uri targetUri = new Uri(Address.Text);    
WebView1.Navigate(targetUri);
string content = WebView1.GetDocument(); //How can I get the document loaded from the target Uri?
我看过MSDN中的API,但没有看到任何值得注意的内容

我想我可以连接到
FrameNavigationStarting
,捕获Uri并通过
WebClient
启动一个单独的请求,但这似乎是一个简单问题的笨拙解决方案

我一定是遗漏了什么-请帮助。

Windows 8: 您可以通过以下方式获取WebView页面内容:

private void webView_LoadCompleted_1(object sender, NavigationEventArgs e)
{
    WebView webView = sender as WebView;

    string html = webView.InvokeScript(
        "eval",
        new string[] {"document.documentElement.outerHTML;"});

    // Here you can parse html ....
}
Windows 10更新:
InvokeScript()
在Windows 10中引发以下异常:

App1.exe中发生“System.NotImplementedException”类型的异常,但未在用户代码中处理

附加信息:未实现该方法或操作

改用
InvokeScriptAsync()

XAML:


是否要检索我们经常使用的
文档
。getElementById('MyTextbox')?@Xyroid,我的意思是获取服务器返回的响应。如果它是HTML,那么我需要HTML文档、JSON、JSON和XML,等等。我该怎么做?我是API新手。你可以在webview和应用程序之间使用javascript进行通信。我仍然不知道如何从webview中获取任何东西,返回到应用程序中。在我执行javascript之后,我如何从WebView中获得结果?我知道我可以从应用程序到网络视图进行单向通信,但反过来呢?
<WebView Source="http://kiewic.com" LoadCompleted="WebView_LoadCompleted"></WebView>
private async void WebView_LoadCompleted(object sender, NavigationEventArgs e)
{
    WebView webView = sender as WebView;

    string html = await webView.InvokeScriptAsync(
        "eval",
        new string[] { "document.documentElement.outerHTML;" });

    // TODO: Do something with the html ...
    System.Diagnostics.Debug.WriteLine(html);
}