Implement Splash Screen with WPF (2024)

  • Download demo - 23.06 KB

Introduction

Now almost all applications have a splash screen. This screen will be shown when the application starts, after the main window of the application isshown, this screen will be closed.

Implement Splash Screen with WPF (1)

Demo effect, the application is loading modules.

Background

WPF has provided an easy way to implement splash screen.Using this way, we should add an image as resource to the project, and set its BuildAction property to “SplashScreen”. This feature is only supported on .NET Framework 3.5. When the application starts, the image will be shown at first as the splash screen. I know this way is implemented via WinForm technology.

The above methodis easy, but it is too simple and doesn’t meet my requirements. My requirements of splash screen are:

  • The way of show the screen is reusable, thus each application I made can use the same way to show a splash screen
  • The splash screen is easy to customize, thus each application I made can have different splash screens and I can make it as beautiful as I can
  • The splash screen can show messages to the user, for example show the loading progress of the application
  • The splash screen may not be a regular shape, it may be a circle and other not rectangle shape, but this is not necessary and important to me

Normally a splash screen has thebelow features:

  • The splash screen doesn’t show in the task bar
  • The splash screen is always shown at the center of the screen
  • The splash screen doesn’t have window title bar and border, it is not resizable

My Design

To meet the above requirements, my design is as below:

Implement Splash Screen with WPF (2)

  • App

    App class inherits from Application class and provides the application entry.
    When entering the Main method, initialize the splash screen and show it by calling theSplasher class, and then run the application, show the main window.

    C#

    /// <summary> ///  /// </summary> class App: Application { /// <summary> ///  /// </summary> [STAThread ( )] static void Main ( ) { Splasher.Splash = new SplashScreen ( ); Splasher.ShowSplash ( ); // Simulate application loading for ( int i = 0; i < 5000; i++ ) { MessageListener.Instance.ReceiveMessage ( string.Format ( "Load module {0}", i ) ); Thread.Sleep ( 1 ); } new App ( ); } /// <summary> ///  /// </summary> public App ( ) { StartupUri = new System.Uri ( "MainWindow.xaml", UriKind.Relative ); Run ( ); } } 
  • MainWindow

    Application’s main window, it’s just a normal window.

  • SplashScreen

    Splash screen window, it’s just a normal window, this window has the special features that a splash screen should have. I have mentioned it above.

  • Splasher

    A helper class to show and close splash screen window, the splash screen window should be initialized by the application. With this class, I don't care which window is the splash screen, and it’s reusable.

    C#

    /// <summary>/// Helper to show or close given splash window/// </summary>public static class Splasher{ /// <summary> ///  /// </summary> private static Window mSplash; /// <summary> /// Get or set the splash screen window /// </summary> public static Window Splash { get { return mSplash; } set { mSplash = value; } } /// <summary> /// Show splash screen /// </summary> public static void ShowSplash ( ) { if ( mSplash != null ) { mSplash.Show ( ); } } /// <summary> /// Close splash screen /// </summary> public static void CloseSplash ( ) { if ( mSplash != null ) { mSplash.Close ( ); if ( mSplash is IDisposable ) ( mSplash as IDisposable ).Dispose ( ); } }} 
  • DispatcherHelper

    This is a helper class, implement DoEvents method like System.Windows.Forms.Application’s DoEvents method, if there is no such function, the loading message of the splash will not be refreshed correctly. The code is shown below:

    C#

    /// <summary>/// Simulate Application.DoEvents function of /// <see cref=" System.Windows.Forms.Application"/> class./// </summary>[SecurityPermissionAttribute ( SecurityAction.Demand, Flags = SecurityPermissionFlag.UnmanagedCode )]public static void DoEvents ( ){ DispatcherFrame frame = new DispatcherFrame ( ); Dispatcher.CurrentDispatcher.BeginInvoke ( DispatcherPriority.Background, new DispatcherOperationCallback ( ExitFrames ), frame ); try { Dispatcher.PushFrame ( frame ); } catch ( InvalidOperationException ) { }} 
  • MessageListener

    This class inherit from DependencyObject, WPF’s UI element can easily bind to its property and update correctly. This class just receives a string message. To show the loading progress message in the splash screen, I add a TextBlock element to the window, and bind its Text property to listener’s Message property, and when the application is loading, Iwrite messages to the listener.

Final Effect

The final splash screen looks like below. I define the window with a WPF window, the Label at the bottom of the window shows the loading tip messages (progress) of the application.

Implement Splash Screen with WPF (3)

A very simple main window.

Implement Splash Screen with WPF (4)

History

  • Version 1.0 2009.07.20

This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Implement Splash Screen with WPF (2024)

FAQs

How do you create a splash screen in WPF? ›

In the Properties window, click the drop-down arrow for the Build Action property. Select SplashScreen from the drop-down list. Press F5 to build and run the application. The splash screen image appears in the center of the screen, and then fades when the main application window appears.

How do you set a splash screen for PWA? ›

How to create a custom splash screen
  1. The name property is set to the name of your PWA.
  2. The background_color property is set to a valid CSS color value.
  3. The theme_color property is set to a valid CSS color value.
  4. The icons array specifies an icon that is at least 512x512 px.
  5. The specified icon exists and is a PNG.
Apr 16, 2024

What is the purpose of a splash screen? ›

Splash screens serve multiple purposes. They provide a professional and polished look to an application by displaying a visually appealing image or logo. Additionally, they can be used to showcase the brand identity or to convey important information or updates to the user.

How to create popup in WPF? ›

To create a transparent Popup, set the AllowsTransparency property to true . The content of a Popup does not inherit bitmap effects, such as DropShadowBitmapEffect, that you directly set on the Popup control or on any other element in the parent window.

What size is the PWA splash screen? ›

Recommended size: 512x512 or higher. Recommended aspect ratio: 1:1.

How do I test my PWA splash screen? ›

If you simply want to test out the splash screens, visit https://pwa-splash.now.sh and add the app to your home screen when prompted on Android or manualy 'Add to Home Screen' on iOS.

What is the file extension for splash screen? ›

Splash screen files should be at least 2732px x 2732px . The format can be jpg or png .

What are the best practices for splash screen? ›

Splash screen examples best practices

Minimize distractions: Keep the design clean and simple and consistent branding. Avoid unnecessary elements and multiple logos to maintain strong brand recognition. Subtle animations: If you choose to include animations, make sure they are subtle and don't extend the loading time.

Do apps need a splash screen? ›

Every good app uses a splash screen that gives them a unique identity.

How long should the app splash screen be? ›

Splash screens should follow the 3-second rule which states that they should not last for more than 3 seconds. If your splash screen lasts for more than 3 seconds, then it will frustrate regular app users and take away from the user experience.

How to make a splash screen in CSS? ›

Approach:
  1. Create the basic layout or structure of the application using various HTML tags like <h1>,<h3>,<div>, etc. ...
  2. Create the overall structure for the splash screen inside the #splash div. ...
  3. Add CSS styling to style the splash screen, dynamic content, and other elements.
Jul 26, 2024

What is a custom splash page? ›

A splash page is essentially a one-page website that works similarly to a landing page, or the first page site visitors are directed to before entering an official website or ecommerce store.

How do I create a template in splash? ›

To create a custom email template, first go to the Email tab of your event's toolbar. Once you're in the Email Sender, make sure that you're in the My Templates tab (not the Emails tab). Click on the Create Template button. You can choose a pre-made template or start fresh with one of our more customizable options.

How do I add a splash image? ›

Add a splash screen
  1. Add dependencies.
  2. Add a theme.
  3. Create a drawable for the theme.
  4. Specify the theme.
  5. Update your starting activity.
  6. Additional resources.

Top Articles
OEM Glass Vs. Safelite Windshields: Which One Is Right For You?
Raypak Pool Heater RollOut Sw OPEN Code: (Causes & Fixes) - Airlucent
Urist Mcenforcer
Exam With A Social Studies Section Crossword
oklahoma city for sale "new tulsa" - craigslist
Find All Subdomains
Wells Fargo Careers Log In
OSRS Fishing Training Guide: Quick Methods To Reach Level 99 - Rune Fanatics
1movierulzhd.fun Reviews | scam, legit or safe check | Scamadviser
What Auto Parts Stores Are Open
Mylaheychart Login
Cincinnati Bearcats roll to 66-13 win over Eastern Kentucky in season-opener
Babyrainbow Private
Job Shop Hearthside Schedule
Craiglist Galveston
Peraton Sso
How to find cash from balance sheet?
Dr Adj Redist Cadv Prin Amex Charge
Urban Dictionary: hungolomghononoloughongous
Kiddle Encyclopedia
Divina Rapsing
CANNABIS ONLINE DISPENSARY Promo Code — $100 Off 2024
Loft Stores Near Me
Why Does Lawrence Jones Have Ptsd
Play It Again Sports Norman Photos
Understanding Gestalt Principles: Definition and Examples
Sister Souljah Net Worth
Best Boston Pizza Places
Tokyo Spa Memphis Reviews
30+ useful Dutch apps for new expats in the Netherlands
Restored Republic
Rek Funerals
Little Caesars Saul Kleinfeld
2024 Coachella Predictions
Justin Mckenzie Phillip Bryant
The Ride | Rotten Tomatoes
Unity Webgl Player Drift Hunters
9781644854013
Hebrew Bible: Torah, Prophets and Writings | My Jewish Learning
Restored Republic May 14 2023
140000 Kilometers To Miles
Improving curriculum alignment and achieving learning goals by making the curriculum visible | Semantic Scholar
Scarlet Maiden F95Zone
Comanche Or Crow Crossword Clue
✨ Flysheet for Alpha Wall Tent, Guy Ropes, D-Ring, Metal Runner & Stakes Included for Hunting, Family Camping & Outdoor Activities (12'x14', PE) — 🛍️ The Retail Market
Ehc Workspace Login
Crystal Glassware Ebay
2000 Ford F-150 for sale - Scottsdale, AZ - craigslist
Is My Sister Toxic Quiz
Electric Toothbrush Feature Crossword
Coldestuknow
Latest Posts
Article information

Author: Fr. Dewey Fisher

Last Updated:

Views: 5454

Rating: 4.1 / 5 (42 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Fr. Dewey Fisher

Birthday: 1993-03-26

Address: 917 Hyun Views, Rogahnmouth, KY 91013-8827

Phone: +5938540192553

Job: Administration Developer

Hobby: Embroidery, Horseback riding, Juggling, Urban exploration, Skiing, Cycling, Handball

Introduction: My name is Fr. Dewey Fisher, I am a powerful, open, faithful, combative, spotless, faithful, fair person who loves writing and wants to share my knowledge and understanding with you.