Search code examples
c#webview2

'CoreWebView2NavigationCompletedEventArgs' does not contain a constructor that takes 1 arguments


I'm new to C# and the WebView2 control, and I'm trying to make something happen when a webpage inside the control finishes loading.

webView.NavigationCompleted += new CoreWebView2NavigationCompletedEventArgs(WebView_NavigationCompleted);

The code above throws a CS1729 error. What is the correct way to implement what I'm trying to accomplish? Any help appreciated!


Solution

  • Check out the WebView2 C# sample apps. It has a C# example of just what you're trying to do.

    Registering the event handler

                control.NavigationCompleted += WebView_NavigationCompleted;
    

    The event handler

            void WebView_NavigationCompleted(object sender, CoreWebView2NavigationCompletedEventArgs e)
            {
                // ...
            }
    

    See also Navigation Events documentation.