To stop the link from opening in a new window, you subscribe to the CoreWebView2_NewWindowRequested
as you have found out.
To do that, the easiest way is to subscribe to the CoreWebView2InitializationCompleted
first.
In properties window for the WebView2
control, double click CoreWebView2InitializationCompleted
- that will auto generate the eventhandler:

Now you add the CoreWebView2_NewWindowRequested
eventhandler and set e.NewWindow
to the current CoreWebView2
.
Here's the code (assuming your WebView2
control is called webView21
):
private void WebView21_CoreWebView2InitializationCompleted(object sender, Microsoft.Web.WebView2.Core.CoreWebView2InitializationCompletedEventArgs e)
{
webView21.CoreWebView2.NewWindowRequested += CoreWebView2_NewWindowRequested;
}
private void CoreWebView2_NewWindowRequested(object sender, Microsoft.Web.WebView2.Core.CoreWebView2NewWindowRequestedEventArgs e)
{
e.NewWindow = webView21.CoreWebView2;
}
Now the link opens in the same window (your WebView2
control).