user3430550
user3430550

Reputation: 1

Can I make WebBrowser translucent and borderless in WPF?

I am finding that setting the Opaque value has no effect. Also there is always a border around the WebBrowser.

Upvotes: 0

Views: 514

Answers (1)

Grant Winney
Grant Winney

Reputation: 66449

From the WPF WebBrowser page on MSDN:

The WebBrowser control internally instantiates the native WebBrowser ActiveX control.

So it's not an actual WPF control... just a wrapper around a native control that allows little customization.

Here's a blog that summarizes what you can't do with the ActiveX control pretty well:

If you add a Win32 component into a wpf application using the hwndhost control you have some limitations:

  • Resizing is limited because only the container(hwndhost) will be resized, not the contained component itself.
  • Forget about rotation and skewing.
  • The hosted component is a black hole for your application : always at the top (forget the z-order!).
  • Opacity can’t be applied to an hosted Win32 control.
  • VisualBrush do not work with Win32 controls.

He goes on to explain a work-around that would come with WPF 4.5, but I can't find anywhere that those promised features ever shipped. They don't appear to have.


About the border.. when I test it I don't have one. But if you do, I'm guessing there's no way to remove that either.

Here's what I see in a small test project (the WebBrowser has a margin of 20px, and it's inside of a GroupBox with 20px padding):

enter image description here

Upvotes: 1

Related Questions