添加 Silverlight 启动画面的最短显示时间
在网页上托管 silverlight 应用程序时,可以使用 splashscreensource
参数来指定在下载真实 xap 文件时显示的简单 Silverlight 1.0 (xaml+javascript) 控件,并且该控件可以接收通过 onSourceDownloadProgressChanged
通知下载进度。如果 xap 文件在缓存中,则不会显示启动屏幕(如果下载只需要 1 秒,则启动屏幕将仅显示 1 秒)。
我知道这通常不是最佳实践,但我正在寻找一种方法来指定启动屏幕的最短显示时间 - 即使 xap 缓存或下载速度很快,启动屏幕至少会保持打开状态,让我们例如,5 秒(例如,显示所需的法律免责声明、公司身份标记或其他错误)。
我确实想专门在启动屏幕中执行此操作(而不是在主 xap 中),因为我希望它干净且不间断(例如声音错误),并在用户打开页面时立即显示给用户,而不是下载后(可能需要 1 到 20 秒以上)。
我不想通过预加载来实现这一点 - 用完整的 Silverlight xap 应用程序(带有它自己的加载屏幕)替换启动屏幕,然后在最短的等待时间后以编程方式加载并显示完整的 xap。
When hosting a silverlight application on a webpage it is possible to use the splashscreensource
parameter to specify a simple Silverlight 1.0 (xaml+javascript) control to be displayed while the real xap file is downloaded, and which can receive notification of the downloads progress through onSourceDownloadProgressChanged
. If the xap file is in cache, the splash screen is not shown (and if the download only takes 1 second, the splash screen will only be shown for 1 second).
I know this is not best practice in general, but I am looking for a way to specify a minimum display time for the splash screen - even if the xap cached or the download is fast, the splash screen would remain up for at least, let's say, 5 seconds (for example to show a required legal disclaimer, corporate identity mark or other bug).
I do want to do it in the splash screen exclusively (rather then in the main xap) as I want it to be clean and uninterupted (for example a sound bug) and shown to the user as soon as they open the page, rather then after the download (which could take anywhere from 1 to 20+ seconds).
I'd prefer not to accomplish this with preloading - replacing the splash screen with a full Silverlight xap application (with it's own loading screen), which then programmably loads and displays the full xap after a minimum wait time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一个鲜为人知的事实是,启动画面在 XAP 加载时间之后仍然存在。在应用程序
RootVisual
加载之前,它不会被替换。因此,如果您不在应用程序Startup
事件中分配RootVisual
,则初始屏幕将永远显示。因此,您可以使用如下代码将启动画面的显示延迟几秒钟:-
这可以使用响应式框架进行简化:-
然而,响应式框架至少会增加 Xap 的大小 66KB,因此仅使用您已经使用的它使用响应式的东西来做其他事情。
Its a little known fact that the splash screen remains in place beyond the time that XAP takes to load. It doesn't get replaced until the application
RootVisual
loads. Hence if you don't assign theRootVisual
in the applicationStartup
event the splash screen displays forever.Hence you can delay the display of the splash for a few seconds using code like this:-
This can be simplified with the Reactive framework:-
However the Reactive framework adds at least 66KB to the size of your Xap so only use it you are already using the Reactive stuff for other things.
请注意,如果您只想在开发过程中延长启动屏幕的显示时间,那么添加 Fiddler 规则即可非常简单,该规则会延迟 Xap 文件的响应。
这是具有这种效果的规则的示例。请参阅 Pedro Forte 的帖子< /a> 了解如何应用该规则的详细信息 - 这真的非常简单!
Note that if you were only interested in extending the display time of the splash screen during development then it is very simple to add a Fiddler rule which delays the response off the Xap file.
This is an example of a rule that would have this effect. See Pedro Forte's post for details on how to apply the rule - it is really very easy!