views:

58

answers:

5

I need an embedded WebBrowser control in my application, and am having problems displaying WPF content on top of it. The application will sometimes show popups for editing data or to display errors, and the WebBrowser is getting drawn on top of the popups because it is a WinForms control.

The alternative I looked at here uses a Popup control to put items on top of the WebBrowser control, however my problem with Popups is they stay open when you switch to another application, and they do not move with your application when the user resizes/moves the app.

Is there an alternative way I could do this? The embedded web content is aspx pages and so not static HTML.

A: 

You could use Adorner's to achieve this. http://msdn.microsoft.com/en-us/library/ms753340.aspx

Avatar
The AdornerLayer still seems to be rendered below the WinForms layer, which is where the WPF WebBrowser Control is rendered
Rachel
A: 

One way you can get around airspace issues is by creating a new frameless window and positioning it on top the webbrowser control. The main problem with this is keeping it positioned properly when the main window get moved/resized/etc.

mdm20
A: 

The WPF 4.0 Chromium WebBrowser project is an alternative to the built in WebBrowser control that should do what you need.

Kris
I've tried that but cannot seem to get it compiling on my machine.
Rachel
+2  A: 

Embedded WebBrowsers suck, unfortunately. If you're displaying actual, real, dynamic web content in your WebBrowser, you have to go through the pain of linking another Window to your hosted WebBrowser's window, and handling moving/resizing/et al yourself. I haven't seen another way that works.

If you're displaying static content (or content from a source that you can control or influence), you might consider displaying, say, RTF docs in a DocumentViewer instead, which doesn't have the icky airspace issues of the WebBrowser control.

FMM
Unfortunately my web content is dynamic
Rachel
Marking this the answer since it explains the problem best. What I actually did was create a global style for WebBrowser controls which hides them when a popup is visible. If I ever need the web content to be usable while the popup is open I'll see about implementing a 2nd window and handling the resize/move problem then, but for now this suits my purposes.
Rachel
A: 

Another methodology that I've had some success with was to play around with clipping regions to essentially cut holes in the ActiveX control that is essentially hosted within these WebBrowser wrapper controls. If I have time I'll write up a demonstration of what I've found and try to include an example but I just wanted to share this in case somebody has more time to look into and can beat me to the punch.

jpierson