如何在应用程序启动时预加载 Prism 视图?
我们使用 Prism 4 for WPF 以及 Prism 附带的导航功能。
当导航到(加载)应用程序中的某些视图时,我们注意到延迟 - 这是可以理解的,这是由于实例化视图及其依赖项而导致的,这包括从磁盘加载必要的程序集。
我们希望在应用程序启动时预加载这些视图,同时显示启动屏幕或类似的内容。
有没有人做过类似的事情并愿意分享他们的经验?
We use Prism 4 for WPF as well as the navigation functionality which comes with Prism.
When navigating to (loading) certain views in our application we notice a delay - which understandably comes from instantiating the view and its dependencies, this includes loading necessary assemblies from disk.
We would like to preload these views at application startup while showing a splash screen or something similar.
Has anyone done something similar and would like to share their experiences?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们还没有找到一个“干净”的解决方案来做到这一点。但这就是我们解决问题的方法。
在引导程序函数 InitializeShell() 中,我们导航到要预加载的所有视图。最后,我们导航到我们想要在主屏幕上显示的所有视图。
这不是一个理想的情况,如果您有很多视图,可能会带来大量的维护工作。这对我来说很有效,但我也很感兴趣是否有人有更好的解决方案。
We haven't found a "clean" solution to do this yet. But this is how we have solved it.
In the bootstrapper function InitializeShell() we navigate to all views we want to preload. As last we navigate to all the views we want to show in our homescreen.
It's not an ideal situation and can give lots of maintenance work if you have a lot of views. This does the job for me, but I'm also interested if anyone has a betters solution.
我不知道这是否有帮助,但我使用以下技术:
1) 将所有需要的程序集的引用添加到我的 shell
2) 使用 WPF 工具包 中的繁忙指示器
I don't know if this can help or not, but i use the following techniques:
1) add a reference off all needed assemblies to my shell
2) use busy indicator from WPF toolkit