Library / workaround for transparent Webview on Win8?

I am looking for a way to create Webview on Win8 (aka-style applications) with a transparent background. If I set the background to transparent in HTML, the background of the Webview is always rendered in white

In the Microsoft forum, I read a message stating that this feature is not available: http://social.msdn.microsoft.com/Forums/nl-BE/winappswithcsharp/thread/c47c0f2e-b2c7-4691-8a20-929174504877

Is there a library or workaround to get Webview transparency?

+4
source share
2 answers

Just set the WebView property DefaultBackgroundColor = "Transparent" in XAML:

<WebView DefaultBackgroundColor="Transparent"/> 
+4
source

There is a workaround for this; it uses WebViewBrush to draw a webview into a rectangle.

First of all, put your webview along with the rectangle:

 <Grid> <WebView x:Name="WebView6" /> <Rectangle Opacity="0.5" x:Name="Rect1"/> </Grid> 

After your webview is ready and loaded (you can use the LoadComplete event for the WebView), you can run this code:

 WebViewBrush b = new WebViewBrush(); b.SourceName = "WebView6"; b.Redraw(); Rect1.Fill = b; WebView6.Visibility = Windows.UI.Xaml.Visibility.Collapsed; 

Which draws a webview onto a rectangle and then collapses the webview.

Now there is a transparent rectangle showing your web view.

Unfortunately, you cannot interact with web browsing this way!

Edit: I use this workaround myself and can be found in the msdn doc: http://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.ui.xaml.controls.webviewbrush

+3
source

Source: https://habr.com/ru/post/1432509/


All Articles