Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Making WebBrowser Transparent

I am trying to make a WebBrowser control on my Windows 7 Phone app transparent, so it can have the same theme as the rest of the app, but I have had no success with anything I have tried. I need to still be able to see the HTML text, but just have the background be transparent. Using CSS in the control doesn't seem to work, and I can't get it to work via XAML either. Is this possible? This post, was not encouraging.

like image 767
Woody Avatar asked May 25 '11 14:05

Woody


1 Answers

This isn't possible. The browser engine always renders a background color for the HTML page. You can assign a color to the BODY tag but a value of 'transparent' will always end up white. The Background color you assign to the WebBrowser XAML element really has no effect as the browser engine essentially renders over the top of it.

Your best bet to match your app theme is to pass the app theme background color into the HTML page via InvokeScript to a Javascript function that will then set it on the BODY element. This assumes that you have control of the HTML content you are loading. (Also, don't forget to enable script via IsScriptEnabled.)

like image 195
Skeets Avatar answered Sep 25 '22 13:09

Skeets