C# Create a WPF Splash Screen

C# Create a WPF Splash Screen

In this post we will create a simple Splash Screen for a WPF application.

Assets

Within the Visual Studio project create a folder called Assets with a sub folder called Images/ Once this is done add a .png file called BackGround.png, ensure you set the properties Build Action to Resources and Copy to Output Directory to Copy if Newer.

Materials Design

First we want to add a Nuget Package called Materials Design, this can be easily done by editing the Project.cs file and adding the following Package Reference.

C#

Once this is done we can update the App.xaml file by adding the following Application Resources.

C#

Splash Screen Window

Next we will add a new XAML Window called SplashScreen to the project.

SplashScreen.xaml

Next we will edit the SplashScreen.xaml file, to layout the splash screen.

XML

SplashScreen.xaml.cs

The code below manages the length of time the splash screen is displayed, after which it will close the splash screen and then display the main window.

C#

StartUp URI

Finally we can change the StartUpUri to point to the new Splash Screen window.

XML

Executing the Code

When the code executes we should first see the following Splash Screen then the Main Window shortly afterwards.