I have a question in WebView2 I have loaded a page, if its content changes I need to reload?
In previous project using WebBrowser.DocumentCompleted, now is not using WebBrowser.
Thank you
I have a question in WebView2 I have loaded a page, if its content changes I need to reload?
In previous project using WebBrowser.DocumentCompleted, now is not using WebBrowser.
Thank you
I would suggest you try the following in you WPF project.
In your window XAML
<WV:WebView2 x:Name="WebView"
Source="https://YOURURL" CoreWebView2InitializationCompleted="WebView_CoreWebView2InitializationCompleted" />
In your code behind use somthing like this. You need to wait for the CoreWebView2 to object to be created.
private void WebView_CoreWebView2InitializationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e)
{
if (e.IsSuccess) System.Diagnostics.Debug.Print("WebView is ready for native window.");
this.WebView.CoreWebView2.NavigationStarting += CoreWebView2_NavigationStarting;
this.WebView.CoreWebView2.NavigationCompleted += CoreWebView2_NavigationCompleted;
}
private void CoreWebView2_NavigationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationCompletedEventArgs e)
{
Debug.Print("++++++++++++++++++++++++NavigationCompleted++++++++++++++++++++++++++++");
Debug.Print("NavigationId: " + e.NavigationId.ToString());
Debug.Print("URL: " + this.WebView.CoreWebView2.Source);
Debug.Print("++++++++++++++++++++++++++++++++++++++++++++++++++++");
}
private void CoreWebView2_NavigationStarting(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NavigationStartingEventArgs e)
{
Debug.Print("#######################NavigationStarting##############################");
Debug.Print("NavigationId: " + e.NavigationId.ToString());
Debug.Print("URL: " + e.Uri);
Debug.Print("#####################################################");
}