0

Hi I have been using webview2 for a while now on my projects, but I want it to open a new tab and not a new window, I also been using easytabs

my code as of right now is

 e.NewWindow = webView.CoreWebView2;
ParentTabs.AddNewTab();

i have done a lot of research and cant seem to find any solution. i opens a new window and a new tab which displays the home page

Foreverably
  • 83
  • 1
  • 5
  • Does this answer your question? [Create tabs using WebView2 - Edge](https://stackoverflow.com/questions/62799506/create-tabs-using-webview2-edge) – Poul Bak Mar 30 '21 at 22:36

1 Answers1

0

You should have a look at Create tabs using WebView2 - Edge.

WebView2 doesn't directly support tabs, but whenever a CoreWebView2 wants to open a new window you can use the CoreWebView2.NewWindowRequested event to provide a new CoreWebView2 placed in the UI however you like. For instance, you can place a WebView2 control as the content of an easytab and then provide the CoreWebView2 of that control back to the NewWindowRequested event args. The linked answer above has sample code.

David Risney
  • 3,886
  • 15
  • 16
  • that's what I was looking for but, like I said I was using easy tabs which is what this is http://lstratman.github.io/EasyTabs/images/screenshots/repositioning.png it mimics chrome tabs, but I was trying to say that I have `ParentTabs.AddNewTab();` added but adds the new tab but in that tab it never opened that link in the new tab – Foreverably Mar 30 '21 at 21:06
  • I would guess you create a new WebView2 for the new tab, is that correct? The new tab's WebView2's CoreWindow is what you need to set in e.NewWindow in order for that new tab's WebView2 to be connected up to act as the new window. In your code you pasted above, you set your e.NewWindow to webView.CoreWebView2 and then you create a new tab so I would guess based on that, that you are not connecting up the new tab's WebView2, but rather you are maybe using the current WebView2's CoreWebView2. Its hard to tell from the limited info you have here. – David Risney Mar 31 '21 at 16:30