-
Notifications
You must be signed in to change notification settings - Fork 55
When using Webview2 in WPF, unable to overlay WPF controls on the Webview #286
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
Comments
Currently WPF WebView2 does not have the ability to not be the topmost control. Could you give me some more context on what you're building and why you'd like the WebView2 control to be 'underneath' other controls? |
I have a application where I have a full screen Webview2 control in a view and want to overlay navigation buttons to allow navigation to other WPF views in the application. Am I right in my thinking that you are just hovering a chromium control over the WPF application in the position specified by the XAML which is perhaps the issue with the startup being incorrectly sized as the actual size doesn't update until the XAML view is resized or refreshed? |
Right now, the WebView2 the control uses HWND hosting, which is why it is the top-level object. We are working on adding visual hosting support which will allow WebView2 to be used independent from an HWND that will allow you you overlay WPF controls over WebView2. However we do not have this support yet. For now, could you perhaps have the WPF controls above the WebView2? The WPF getting started guide can be a good place to start: https://docs.microsoft.com/en-us/microsoft-edge/webview2/gettingstarted/wpf |
Thanks, I am glad that the future Development will hopefully allow a true integration of the Webview2 with proper Z index control. |
I have a WPF application where I migrate parts to HTML5 step by step. For the display I use WebView2. Popups, dialogs or tooltips are still implemented in WPF and cannot be displayed because of the overlay problems. |
Same issue as amentma73 - we just did a small prototype to replace WPF controls with WebView2 and were blocked by the overlay problem. It would be great to get an estimate, when this might be fixed. |
I've used WebView for well over a decade in the mapping industry as a quick way to bring feature rich interactive maps to WPF apps. Web based mapping platforms often have more features than their .NET counter parts and are updated much more frequently, so creating a wrapper using WebView has been a great way to unlock those features in .NET apps. However, for just as long I have come across a constant stream of requests from developers who want to be able to overlay other WPF controls above WebView (most of which was unrelated to what I was working on, and just what I came across as complaints elsewhere). From the mapping side its often that they want the popup or navigation controls for the map to use standard WFP controls. Note that the map is generally thought of as a background canvas in apps with user data overlaid above it. So I definite +1 this request and am sure there will be a lot of happen developers if this is supported. |
Anyone tried using the following and checked if it works?
|
I'm using WebView2 in WPF, and there doesn't seem to be any 'WebViewExecutionMode'. |
I tried with WebView and not WebView2. |
Any update on or even better ETA on "We are working on adding visual hosting support which will allow WebView2 to be used independent from an HWND that will allow you you overlay WPF controls over WebView2."? |
+1 One from my side. Somehow the VS team already solved it in a generic way, the XAML editor preview does exactly what I would like to be able: render other content on top of any control. And properly interact with it. Should be easy for someone at MS to build in such feature into WebView2. In fact, i do get solid 60Hz with WebView2-WebGL content in the XAML-Editor. ;) While CefSharp runs at 30Hz or lower (depending on the resolution) at runtime. |
@dos-ise I would suggest you look at work arounds. People using the WPF Webbrowser control have been waiting more than 10 years for a fix to the airspace issue :-) For your use case have a look at this github project. As you want to display a dialog over the top of your WebView2 the user does not need to interact with the browser while it is showing. Before showing your dialog - take a pic, replace your webview2 with the pic and then show your dialog. By the way to get your image use the WebView2 method to get it and not what is in github. Your other alternatives are to show a new window or show a popup - both these have their own window handle different to the window that your webview2 is on and thus will display fine. |
I've got a question about this issue. I saw in the Release Notes for the WebView2 SDK (https://docs.microsoft.com/en-us/microsoft-edge/webview2/releasenotes#10790-prerelease) that Visual Hosting is now supported. Does this solve the Problem regarding "Web Renderer is always on top"? And if yes how exactly do I have to initialize WebView2 in a WPF Application? |
I have been looking at that too. I am Adding an answer to this question in the hope that if I am incorrect I will be corrected you MS engineers. First the composition interface currently only appears to be available in C++. Secondly it appears to be a kind of overlay to intercept mouse interactions and for example drag and drop. I think that this overlay will eventually allow for webview2 to be able to intercept the mouse interactions so that for example win forms and WPF can do this as well. |
Any updates on this? |
We would like to embed WebView2 in a fairly complex WPF UI. When will this problem be fixed? Is there a way to track progress on this issue? |
The request to have support for the basic behavior of a WPF control (such as being aware of the zpanel.index and visual tree when rendering) was done over a year ago, any ETA for this fix? |
Any update on this please? |
The same issue, the webView2 is being on top always, popups are going behind this window. any update on this, please? |
Hello @ChrisPulman , I am also having a similar requirement, can you please provide a sample code that I can use to make it happen. Tried using this https://github.com/chris84948/AirspaceFixer but not had much luck. |
Is there a way to fix the Microsoft.Windows.SDK.NET problem that @mr-luiks describes without changing the target OS version? Ours is set to Windows 7. |
Using the For .NET Framework I get this exception:
For .NET 6+ I get this exception:
|
已收到您的邮件,我会及时查看的!
|
You missed somewhere above the comment that you need to install the optional directX component, |
@psmulovics Hey brother, thanks for chiming in. Yes, I did miss that. Well, that makes creating a reusable control library that ships via Nuget a little more of a pain. |
Why is this optional DirectX component required though? I mean if Edge is installed and working, why would wrapper need system level component DirectX? |
It is only needed if you to want to overcome airspace issues - and it is the same requirement you have for other solutions regarding airspace |
Hi, Not sure I follow this. Can you please clarify that if we want to deploy an app that uses the new composition control, all our users need to run that dism command to install an optional windows feature? Thanks |
You shouldn't need to use the dism tool to install Tools.Graphics.DirectX for either development or deployment. I've just discovered and have a fix for a bug where an incorrect flag was being passed in during Direct3D device creation. With the tools installed this was a no-op, but without the tools it became a crash. The next version of the prerelease SDK should have the fix, but in the meantime for your development, please install those tools as a workaround:
|
HI @champnic , @zhuhaichao518 and @ChrisPulman It's been more than 3 years waiting for the solution to the "AIRSPACE" issue with WebView2. We are waiting since Composition control is an alternative solution that did not solve the issue of AIRSPACE completely. Please let us know when we can expect the fix and the next release of WebView2. |
Thanks @champnic I have been critical of this issue before and had basically given up on it, but having tried the new composition control, it does indeed fix the issue pretty much perfectly from my tests. Barring the issue of having to install an optional package (which is still a show stopper if we're doing public releases), once that is fixed and the composition control becomes available in the production release, this will be hugely helpful and a great addition for anybody working with WPF. So, keep up the good work on this and my thanks to the team for this effort 👍 |
That's sad. The first pre-release worked fine without that requirement. |
All of the versions required this Windows API support, so would have failed downlevel at runtimes anyways. Specifying Windows version is only required when using .NET 5+, and isn't required when using .NET Core 3.0/3.1 or .NET Framework. The first versions of the SDK didn't support .NET 5+ at all, therefore didn't have the Windows version requirement. |
It's 2024 yet to be resolved? A lot of my pop-up notification controls are disabled in order to use WebViews🤣 |
Can you tell us if there is a current schedule? thx. @champnic |
Please note that the nupkg I shared with @cmiles does not come with any ongoing compatibility or support guarantees, so I wouldn't recommend actually shipping with it. But it is useful for validation and early development. @alexinea The WebView2CompositionControl has been promoted to stable, and will be released with the next release SDK package sometime in January. I'm trying to get the fix for #4941 that @cmiles reported also ported back to that version before release. |
Hi @champnic , I tried the pre-release version of the SDK (1.0.2950-prerelease), found the drag behavior (msWebView2EnableDraggableRegions) is lost. Will this be fixed in the release version. |
已收到您的邮件,我会及时查看的!
|
来信收到。thanks.
|
With the release of the API Show WPF elements on top of the WebView2 layer (WebView2CompositionControl). Closing the issue. Please let us know, if you still got queries around it. |
Uh oh!
There was an error while loading. Please reload this page.
Webview2 is topmost and any WPF controls are hidden behind the webview2 component.
Tried setting the Z index without any success.
Should be able to set visibility level by the position in the XAML tree
AB#27046547
The text was updated successfully, but these errors were encountered: