Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

With WebView2 inside a C# DialogForm : after call to Hide(), WebView2 stay visible #828

Closed
Phildre92 opened this issue Jan 16, 2021 · 7 comments
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@Phildre92
Copy link

Phildre92 commented Jan 16, 2021

Description
I have a WebView2 inside a C# DialogForm.
The Hide() Function close the DialogForm but WebView2 window stays visible as a top level window.
There a similar problem with Show() for a DialogForm, WebView2 stays invisible.

To "solve" this problem, I have managed myself visibility of WebView2 window :

  • using DialogForm.Shown Callback to add an explicit call to WebView2.Show()
  • using DialogForm.FormClosed to add an explicit call to WebView2.Hide

There is also a similar problem when the WebView2 is in TabPanel.

Version
Microsoft Visual Studio Community 2019
Version 16.8.2
VisualStudio.16.Release/16.8.2+30717.126
Microsoft .NET Framework
Version 4.8.04084
Visual C++ 2019 00435-60000-00000-AA288
Microsoft Visual C++ 2019
Package Microsoft Visual Studio VC 1.0
Package Microsoft Visual Studio VC

SDK: Microsoft.Web.WebView2 1.0.674-prerelease

Runtime: Canary Version 89.0.767.0 (Version officielle) (64 bits)

Framework: WinForms

OS: Win10

AB#31680887

@Phildre92 Phildre92 added the bug Something isn't working label Jan 16, 2021
@Alex240
Copy link

Alex240 commented Feb 3, 2021

I have the same problem (VB.NET), the bug seems random.

@oggy22 oggy22 added the tracked We are tracking this work internally. label Feb 10, 2021
@oggy22
Copy link
Member

oggy22 commented Feb 10, 2021

Thank you for reporting this issue. Having our WebView2 inside a ShowDialog does seem as something we didn't quite cover with our testing. We will work on it and get back to you.

@SamuelQZQ
Copy link
Contributor

@Phildre92 What's the namespace of the DialogForm you mentioned? Is that Microsoft.Web.Management.Client.Win32.DialogForm? I'm trying to repo the bug. But I haven't found this control.

@Phildre92
Copy link
Author

Phildre92 commented Apr 28, 2021

I'm using "Microsoft.Web.WebView2.WinForms.WebView2 " in a "System.Windows.Forms".
This "System.Windows.Forms" is managed by "ShowDialog()" to be modal.

"visible" field of "WebView2" seems to be compliant with visible forms status. But after closing the forms "WebView2.visible = false" but "WebView2" is always shown.

"WebView2" is shown on the first call to "ShowDialog()", but then not hidden when closing the form clicking on the window manager cross in the upper right corner of the window.
Adding manual "Hide()" in closed callback of the form hides "WebView2" but then "ShowDialog()" shows the form but not "WebView2".

To open "WebView2" included in this modal form, i need to add callback "System.EventHandler(this.Item_Form_Shown)" to the form. These callback call "show()" on "WebView2".

To close "WebView2" included in this modal form, i need to add callback "System.Windows.Forms.FormClosedEventHandler(this.Item_Form_FormClosed)" to the form. These callback call "Hide()" on "WebView2".

@iamshz97
Copy link

iamshz97 commented May 1, 2021

Same Issue w/ ME

         using (var myWebView2 = new myWebView2())
                {
                    carfaxForm.ShowDialog();
                }

Helped my case.

@styletronix
Copy link

It's also when the Form is displayed as MDI Child in a tabbed MDI Controller. When there is no other Window inside the tabbed MDI Container the WebView is hidden when form.hide() is called, but if there is another form in the tabbed mdi container, the webview stays on top as a seperate formless window. It reattaches itself if the containig form is shown again.

Setting form.mdiparent = nothing before hiding the form and reattaching it to the mdiparent when shown solved the issue, but that is only a workarround.

@champnic
Copy link
Member

champnic commented Jun 5, 2021

This should be fixed in 1.0.902-prerelease SDK. Thanks!

@champnic champnic closed this as completed Jun 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

7 participants