Author : Admin
Last Modified : 21-Dec-2019
Complexity : Beginner

Implement Splash Screen in WPF


Applications are getting richer and taking time in launching. Developer spends a lot of time to reduce this starting (Launch time)time of application but it has a limit so these application needs some screen to show immediately when launch. This starting screen (Splash Screen) provides a responsive user experience before the first window of application shown to the user. Or we can understand this like this way. Sometimes our first window took time to render when a user launches the application. In this case, a splash screen is shown.

Wpf provides two ways to enable your application with the Splash screen.

  1. Use Image direct as splash Screen
  2. Use SplashScreen class

1. Image direct as Splash Screen

  • Create a WPF project.
  • Add Image file to the project that you want to show as Splash screen.
  • In the Solution Explorer, right-click on that image and choose the property.
  • In the Property Window, Select Splash Screen option for the Build Action property.
  • Now, Do F5 to run the application and you can see your splash screen.

a) Add SplashScreen Image in the project.

 

b) In Property Window > Build Action choose SplashScreen option

 

c) Now run the application, you can see the Splash Screen for your application

Splash Screen

 

2. Use SplashScreen class

.Net provide class SplashScreen under System.Windows namespace. By using this class we can create a startup screen. 

Create the Object of SplashScree and Pass image path in the constructor and call Show method. Use this SplashScreen class on the startup code block. I used it in the OnStartup method inside the App class. If you are not aware of the App class and OnStartup method, you can refer to the link provided below the article.

See the code block how to use it

using System.Windows;

namespace SplashScreenDemo
{
    /// <summary>
    /// Interaction logic for App.xaml
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            SplashScreen splashScreen = new SplashScreen(@"/Image/SplashScreen.png");
            splashScreen.Show(true);

        }
    }
}

 

If you don't know about startup method please refer link