CefSharp web浏览器实例中的WPF(透明度) [英] CefSharp WebBrowser Example in WPF (transparency)

查看:3042
本文介绍了CefSharp web浏览器实例中的WPF(透明度)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我与WPF和C#(使用Visual Studio 2013年)工作,我想开发一个透明的背景和一个WebBrowser的应用程序。据我所知,这是默认的web浏览器的问题......但我想找到另一种解决方案。我发现其他的web浏览器的组件一样,是基于铬CefSharp。我想知道,如果是可以用一个透明背景使用CefSharp浏览器,我想有人给我解释一下如何一步一步实现一个非常简单的网页浏览器(我发现了一些文章,但我没能实现工作应用)。如果你认为还有其他更好的组件请建议我解释一下我如何使他们的工作。
感谢您的关注和答复。

I'm working with WPF and c# (using Visual Studio 2013) and I want to develop an application with a transparent background and a webbrowser. I understand that this is an issue of the default webbrowser... but I want to find another solution. I found other webbrowser components like CefSharp that is based on chromium. I'd like to know if is possible using a transparent background using the CefSharp browser and I'd like that someone explain me step by step how to implement a very simple webbrowser (I found some article but I was not able to implement a working application). If you think that there are other better components please suggest me and explain me how to make them working. Thank you for your attention and for the replies.

推荐答案

这是概念黑客只是一个快速证明基于 CefSharp.Wpf.Example ,看它是否是可行的。根据你想要什么,我认为这是可能使(部分)的网页透明。

This is just a quick proof of concept hack based on CefSharp.Wpf.Example to see if it was doable. Depending on what you want I think it is possible to make (some) web pages transparent.

在下面的图片中可以看到 CefSharp.Wpf.Example 上的Visual Studio的顶部。还有从CefSharp局部DevTools窗口在左下角前

On the picture below you see CefSharp.Wpf.Example on top of Visual Studio. There's also a partial DevTools window from CefSharp in front in the lower left corner.

下面是我做(参见下图):

Here is what I did (refer to the picture below):


  1. 添加的WindowState =正常不透明度=75AllowsTransparency =真WindowStyle =无了minHeight =400了minWidth =600来的<窗​​GT; 的元素 MainWindow.Xaml

  2. 添加某处时,浏览器被初始化到 ShowDevTools()方法的调用。

  3. 然后我用DevTools设置<车身方式> 的背景阿尔法加载的页面上零

  1. Add WindowState="Normal" Opacity=".75" AllowsTransparency="True" WindowStyle="None" MinHeight="400" MinWidth="600" to the <Window> element of MainWindow.Xaml
  2. Add a call somewhere when the browser is initialized to its ShowDevTools() method.
  3. I then used DevTools to set the <body>s background alpha to zero on the page loaded.

根据你需要什么,你将不得不实验WPF不透明度值自己。这也取决于网页上需要显示取消对不同元素的实际背景颜色可能需要一些调整。正如你可以看到的例子它上面只需要设置一个值移除谷歌搜索页面上的白色背景。您可以使用在CefSharp FAQ wiki页面中提到的 ExecuteJavascriptAsync()方法注入在页面的JavaScript您导航到。

Depending on what you need you will have to experiment with WPF Opacity values yourself. Also depending on the web page you need to display removing the actual background color on different elements may need some tweaking. As you can see from the example above it just needed setting one value to remove the white background on the Google search page. You can use the ExecuteJavascriptAsync() method mentioned in the CefSharp FAQ wiki page to inject JavaScript in pages you navigate to.

这篇关于CefSharp web浏览器实例中的WPF(透明度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆