Implementing the Splash Screen
The implementation is really very simple. At its heart, you’re simply loading in a very lean user control. After this lean view is loaded you then inject your first view, only setting it up so it’s not seen, but the views/controls/subviews/viewmodels all living in XAML get constructed. Once you’re ready, ripping out the splash screen and replacing it with the full content is all that’s left. At the end of the day you can simplify it down to one line in your app.xaml.cs.
App.Xaml.cs
private void Application_Startup(object sender, StartupEventArgs e)
{
if(App.Current.IsRunningOutOfBrowser)
{
SplashscreenController.Initialize(new Splash(), 500, 482, WindowState.Maximized,true, 600);
}
else
{
App.Current.RootVisual = new InstallView();
}
}
and with in the SplashScreenController:
public static void Initialize(UserControl splashcontrol, int width, int height, WindowState postWindowState, bool initializeOnLoad, double minSplashTime)
{
// only run if the rootvisual is null, ie only run when the splash or some content hasn't been shown
if (App.Current.RootVisual == null)
{
...
if (App.Current.IsRunningOutOfBrowser)
{
// ensure window widths match splash width
App.Current.MainWindow.Width = Width;
App.Current.MainWindow.Height = Height;
}
// pull out the type to be activated later
CoreScreenType = typeof(T);
Read more: Cynergy Blogs
The implementation is really very simple. At its heart, you’re simply loading in a very lean user control. After this lean view is loaded you then inject your first view, only setting it up so it’s not seen, but the views/controls/subviews/viewmodels all living in XAML get constructed. Once you’re ready, ripping out the splash screen and replacing it with the full content is all that’s left. At the end of the day you can simplify it down to one line in your app.xaml.cs.
App.Xaml.cs
private void Application_Startup(object sender, StartupEventArgs e)
{
if(App.Current.IsRunningOutOfBrowser)
{
SplashscreenController.Initialize(new Splash(), 500, 482, WindowState.Maximized,true, 600);
}
else
{
App.Current.RootVisual = new InstallView();
}
}
and with in the SplashScreenController:
public static void Initialize(UserControl splashcontrol, int width, int height, WindowState postWindowState, bool initializeOnLoad, double minSplashTime)
{
// only run if the rootvisual is null, ie only run when the splash or some content hasn't been shown
if (App.Current.RootVisual == null)
{
...
if (App.Current.IsRunningOutOfBrowser)
{
// ensure window widths match splash width
App.Current.MainWindow.Width = Width;
App.Current.MainWindow.Height = Height;
}
// pull out the type to be activated later
CoreScreenType = typeof(T);
Read more: Cynergy Blogs