如何更改加载浏览器外 Silverlight 3 应用程序的背景颜色?
在浏览器外运行 Silverlight 3 应用程序时,启动需要一点时间,但时间足够长,足以引起人们的注意。在此启动期间,托管应用程序的窗口的背景显示丑陋的白色背景颜色。在浏览器中运行时,我们有一个启动屏幕,但它当然是通过 JavaScript 加载的。如何让闪屏在浏览器外的 Silverlight 3 上正常工作?或者如果这是不可能的,有没有办法至少可以改变窗口的背景颜色?
When running our Silverlight 3 application out-of-browser, startup takes a little time, but it's long enough to be noticeable. During this startup, the background of the window hosting the application displays an ugly white background color. When running in-browser, we have a splash screen, but that's loaded via JavaScript of course. How can I get a splash screen working for an out-of-browser Silverlight 3? Or if that's not possible, is there a way I can at least change the background color of the window?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。原文
发布评论
评论(2)
我实际上找到了一种方法来做到这一点。万岁!很大程度上归功于 此页面。请注意,我们正在磁盘上分发我们的应用程序;这些说明不适用于用户从 Web 安装的 Silverlight 应用程序。
事实证明,Silverlight 启动器在开始时加载了一个 HTML 页面。在安装应用程序的地方,有一个index.html 文件。该页面包含一个
不幸的是,这个
为了解决这个问题,我将托管 Silverlight 的
的
可见性
设置为隐藏
。然后,在 HTML 的底部,我添加了一个设置计时器的。当计时器触发时,
visibility
更改为visible
,并且 Silverlight 对象获得焦点。即使计时器设置为 1 毫秒,HTML 主机也有机会进行网页的初始绘制。这允许显示 Silverlight 下的任何内容。这是我的整个 HTML 页面:
I actually found a way to do this. Hooray! Much credit goes to the document found at this page. Note that we're distributing our application on disk; these instructions won't work for a Silverlight application installed by a user from the web.
It turns out that the Silverlight launcher loads an HTML page at the start. Where the application gets installed, there's an index.html file. The page contains an
<object>
tag similar to the one used to host Silverlight on the Web.Unfortunately, this
<object>
does not support the Silverlight splash screen XAML or progress indicator, which I guess is to be expected since the XAP isn't being downloaded. Also, setting the background color of the page or of the<object>
also doesn't seem to take effect. However, it turns out that it's just that Windows immediately starts drawing the plugin, so the default window color is shown while doing so.To work around this, I set the
visibility
of the<div>
that hosts the Silverlight tohidden
. Then, at the bottom of the HTML, I added a<script>
that sets a timer. When the timer fires, thevisibility
of the<div>
is changed tovisible
, and the Silverlight object is given focus. Even if the timer is set to 1 millisecond, that allows the HTML's host a chance to do the initial drawing of the web page. That allows any content underneath the Silverlight to show up.Here's my entire HTML page:
不幸的是,Silerlight 3 没有提供自定义的方法。
Unfortunately, Silerlight 3 does not provide a way to customize this.
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!