Today, while trying to debug on a very slow virtual machine, I decided to add a splash screen to my WPF application. After all, my phone applications have one, so how hard could it be?
First I found these instructions on MSDN for adding a splash screen
Wow. That’s easy! However to my surprise, I found that in some circumstances, my application caused a message box to show before the main window was displayed, as my MessageBox was shown by the constructor.
And to my surprise, the splash screen closed that message box. Now I’m not the first to find this problem. There are various discussions and links here, but I have to admit, I didn’t really like any of the three options presented there.
So, I thought, there must be a better way. Well, I think I’ve found one!
First, construct your SplashScreen object as shown in this constructor:
SplashScreen ss = new SplashScreen("Images/splash.png");
// show the splash screen
// do the rest of the constructor work.