You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
private async void WebView_NavigationCompleted(object sender, CoreWebView2DOMContentLoadedEventArgs e)
{
var text = await webView.ExecuteScriptAsync("document.body.innerHTML");
var devToolsContext = await webView.CoreWebView2.CreateDevToolsContextAsync();
await Handle(devToolsContext);
}
public async Task Handle(WebView2DevToolsContext dtc)
{
var body = await dtc.QuerySelectorAsync<HtmlElement>("body");
if (body != null)
{
}
Now the weird bug:
In the application, I click on the button, then it correctly executes the method "WebView_NavigationCompleted" and then the method "Handle".
If I click again, it executes the method WebView_NavigationCompleted and jumps over the method Handle .
If I click again, then it first executes the Handle method and only then goes into WebView_NavigationCompleted.
Do you have any explanation?
The text was updated successfully, but these errors were encountered:
I have a weird problem (and can share you the source, if you like).
I have a WPF with a webview.
I have a Click Button for users to navigate to a URL:
private void Button_Go_Click(object sender, RoutedEventArgs e)
{
if (!_handlerAttached)
{
webView.CoreWebView2.DOMContentLoaded += WebView_NavigationCompleted;
_handlerAttached = true;
}
if (webView != null && webView.CoreWebView2 != null)
{
webView.CoreWebView2.Navigate(tbUrl.Text);
}
}
private async void WebView_NavigationCompleted(object sender, CoreWebView2DOMContentLoadedEventArgs e)
{
var text = await webView.ExecuteScriptAsync("document.body.innerHTML");
var devToolsContext = await webView.CoreWebView2.CreateDevToolsContextAsync();
await Handle(devToolsContext);
}
public async Task Handle(WebView2DevToolsContext dtc)
{
Now the weird bug:
In the application, I click on the button, then it correctly executes the method "WebView_NavigationCompleted" and then the method "Handle".
If I click again, it executes the method WebView_NavigationCompleted and jumps over the method Handle .
If I click again, then it first executes the Handle method and only then goes into WebView_NavigationCompleted.
Do you have any explanation?
The text was updated successfully, but these errors were encountered: