One small but sometimes useful new feature that was bundled with Service Pack 1 (SP1) of Visual Studio 2008 is the Splash Screen feature of WPF. This enables you to create an image file which is then used as splash while the main application spins up and loads.
Probably the main selling point of this feature is its ease of use. Here are the steps involved:
Create or select a suitable image file
- Add it to the project in the Solution Explorer.
- Left-click on the file name in Solution Explorer to select it
- Set its Build Action to Splash Screen.
I chose to use a simple image with some text, but you can be as artistic as you like

At its simplest, that's really all there is to it. If you run the project now, you will see the splash screen appear, followed by the main startup form of the application. If you have a fast machine and a small project, the length of time the splash screen appears may be very short.
This isn't necessarily a problem. After all, the idea is usually to reassure the user that something is happening in the background. If the boot up time is short, then maybe you don't need a splash screen at all.
Of course, you may not know the speed of systems on which your application is going to be installed. Or you may have an opening message that you particularly want to display in any event. In that case, you need some way of controlling how long the splash screen stays on view. And as you probably guessed, this feature is also available.
Remembering that the splash screen is shown at the very start of the application life cycle, it makes sense for the code to be placed in the Application.xaml.vb file. Specifically, in the Application_Startup event.
There are three elements to the code required.
- The first step is to create a variable for the required splash screen.
- The second step is to turn off the AutoClose option of the splash screen (this being the option that you will have seen if you followed the steps first described above).
- Finally, you use the Close method of the splash screen, but set a TimeSpan for the delay before the splash screen totally disappears.
That expression 'totally disappears' bears a little more explanation. What actually happens is that the splash screen fades from an Opacity level of 1 (fully opaque) to a level of 0 (completely transparent) over the period set by the TimeSpan.
Here is the code:
Private Sub Application_Startup(ByVal sender As Object, ByVal e As System.Windows.StartupEventArgs) Handles Me.Startup
Dim splash As New System.Windows.SplashScreen("LoadingScreen.png")
splash.Show(False)
splash.Close(New TimeSpan(0, 0, 6))
End Sub
The above snippet displays the splash screen for 6 seconds.
In most cases, the splash screen works best if you just use it in those cases where you genuinely have, or expect, a delay in the startup. One problem otherwise is that you have to start fiddling with the timing and possibly the opacity of the display of the startup Window so that it synchs with the splash screen. If you don't, then the startup Window may appear (fully opaque) while the splash screen is still gently fading out. This generally doesn't look right. But for a straightforward "Don't worry, this application is working" message to users, the WPF Splash Screen is great.
If you haven't yet installed SP1, you can access it here.