Skip to content

How to create new webView2 window using NewWindowRequested ? #4501

Answered by david-risney
53b4 asked this question in Q&A
Discussion options

You must be logged in to vote

You're mostly on the right track. But there's a couple of issues with your NewWindowRequested handler:

  • Connect the new WebView2 to your new window. In your NewWindowRequested handler you create a new WebView2 and a new Form but I don't see you placing that WebView2 into your new Form window. The NewWindowRequested event from WebView2 wants you to setup a new CoreWebView2 somewhere appropriate for however your app wants to handle new windows.
  • Don't create a new environment synchronously. Perhaps it will happen to work, but you really shouldn't do CreateAsync().Result which will perform a synchronous blocking wait for the environment to be created. This may result in deadlock. More info is…

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by victorhuangwq
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants