Making WebBrowser Transparent

前端 未结 4 1075
走了就别回头了
走了就别回头了 2020-12-07 02:36

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

4条回答
  •  难免孤独
    2020-12-07 03:11

    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.)

提交回复
热议问题