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 applicat开发者_运维问答ion startup while showing a splash screen or something similar.
Has anyone done something similar and would like to share their experiences?
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.
protected override void InitializeShell()
{
base.InitializeShell();
Application.Current.MainWindow = (MainShell) Shell;
// Preload views
// ---- Load (navigate to) all views here you want to have preloaded
// Load actual default views
// ---- Load (navigate to) the actual views for your "homescreen"
// Finished loading now show the shell
Application.Current.MainWindow.Show();
}
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.
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
精彩评论