WP7 中 Web 浏览器控件的透明背景

发布于 2024-12-04 07:38:45 字数 211 浏览 2 评论 0原文

虽然看起来并不乐观,但有谁知道是否可以将网络浏览器上的背景设置为透明,以便应用程序的背景将充当网络浏览器中内容的背景?

我问的原因是我们不是在应用程序中存储一些半静态文本,而是将其存储在网络上并从那里引用它。 (因此,如果我们需要进行更新,则不必更新应用程序)我们在 iOS 和 Android 中拥有透明控件,并且也想在这里进行操作。

如果你做不到,你能想到其他替代方案吗?

While it doesn't look hopeful, does anyone know if it's possible to set the background on a WebBrowser as transparent so the background of the app will serve as the background of the content in the webbrowser?

The reason I'm asking is instead of storing some semi-static text in the app, we are storing it on the web and referencing it from there. (So if we need to do updates, we do not have to update the app) We have transparent controls in iOS and Android, and would like to do it here as well.

If you can't do it, can you think of any alternatives?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

吃不饱 2024-12-11 07:38:46

这是不可能的,因为 WebBrowser 控件不是“真正的”(完全托管)silverlight 控件,它本质上只是本机控件的包装,并且不支持透明度。

作为替代方案,只需从网站获取内容/文本并将其显示在支持透明度的控件中。
根据您从网站获取的内容的格式,这将影响其难度。 WrapPanel(来自工具包)可能会对此类事情有很大帮助。

This is not possible as the WebBrowser control is not a "true" (fully managed) silverlight control, it's essentially just a wrapper of a native control and does not support transparency.

As an alternative, just get the content/text from the website and display it in controls which do support transparency.
Depending on the formatting of the content you are getting from the website will influence how difficult this is. WrapPanel (from the Toolkit) will likely be a great help for this type of thing.

屌丝范 2024-12-11 07:38:46

这是一个穷人对问题的解决方案,但也许会对您有所帮助:如果您只是希望网络浏览器的背景与应用程序的背景颜色完全匹配,那么您可以通过以下方式解决问题强制页面..具有相同的背景颜色。使用 WebBrowser.InvokeScript 并执行一个小的 JS 脚本,该脚本将使用您的 bkgcolor 执行 document.body.background = #rrggbb 。您可能想尝试添加“alpha”,但我认为在最好的情况下您最终会得到白色。

将这种方法更进一步,您可以尝试对应用程序进行屏幕截图,保存它,然后执行 JS 脚本来设置页面的 bkgimage。可以使用 CSS 设置 bkgimage 不随页面内容滚动,所以它实际上可能看起来不错,但我从未尝试过。

据我所知,WebBrowser 最初确实支持设置背景,因为正如 Matt 所说,在内部,它是一个准备 html 内容渲染的本机组件,因此,它对您的应用程序一无所知,并且只是跟上写入页面的确切样式。页面总是有一些背景颜色 - 即。白色 - 因此渲染的图像具有相同的效果。非常相似的“概念”也存在于其他一些平台上 - 例如。 RIM/BlackBerry 4.x、5.x,我想 6.x 也是如此。嗯,但在第二个方面,CSS 不仅支持 #RGB,还支持 #RGBA,因此,只要您使用 alpha 设置页面的主体 bkg 颜色,nativehost 就可以使用适当的 alpha 通道发出渲染。但我想它仍然会变白。

It is a poor man's solution to the problem, but maybe will help you a bit: if you just want the webbrowser's background to match exactly the background color of your application, you may get over the problem just by forcing the page to .. have the same bacground color. Use WebBrowser.InvokeScript and execute a small JS script that will do a document.body.background = #rrggbb with your bkgcolor. You may want to try adding 'alpha' but I think that in the best case you will end up with white.

Taking this approach a small step further, you may try to screenshot your app, save it, then exec a JS script to set bkgimage of the page.. The bkgimage can be set with CSS to not scroll with the page contents, so it actually might look nice, but I've never tried.

From what I know, the WebBrowser does originally support setting the background, because as Matt said, internally, it is a native component that prepares renders of the html content, and as such, it knows nthing about your application and it simply keeps up to the exact styling that is written into the page. The page has always some background color - ie. white - and so the rendered image has the same. Very similar "concept" is also present on some another platforms - fore example. RIM/BlackBerry 4.x, 5.x and I think in 6.x too. Hm, but on the second though, CSS supports not only #RGB but also #RGBA, so the nativehost could emit renderings with appropriate alpha-channel, if only you set the page's body bkg color with alpha. However I suppose it would still turn white.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文