WPF SplashScreen , how to make splashscreen showing longer

12,464

Solution 1

Use the explicit way of showing the splash screen and pass false to the Show method.

That way you have to call Close() explicitly when you want the splash to close.

Solution 2

I opened the App.xaml file, and made these changes to "delay" the showing.

public partial class App : Application
{
    App()
    {
        // Pause to show the splash screen for 3 seconds
        System.Threading.Thread.Sleep(3000);
    }
}

Solution 3

You can use, as Jake Glines wrote, System.Threading

using System.Threading;
public MainWindow()
{           
  SplashScreen splash = new SplashScreen("splash.jpg");
  splash.Show(true);
  Thread.Sleep(1500);           
  InitializeComponent();
}

Or you can use timer/progressbar on it, and make it depend on real loading, not just imaginary.

Share:
12,464

Related videos on Youtube

cnd
Author by

cnd

Updated on June 04, 2022

Comments

  • cnd
    cnd almost 2 years

    I found only one way to make splash display time longer.

    That is changing ApplicationDefinition to Page and configuration it's time.

    But I need ApplicationDefinition, I got locator here and it lost if I use page.

    So I want to make SpashScreen display time and delay before showing main form longer but I also want to save ApplicationDefinition.

    Thank you.

  • cnd
    cnd almost 13 years
    SplashScreen works automatic with ApplicationDefinition on .net 4
  • Emond
    Emond almost 13 years
    Yes, but apparently it does not work the way you want because it only waits until all resources are loaded. If you want to adjust the time you have to explicitly show and close the splash screen.
  • Emond
    Emond almost 13 years
    Sorry, I do not understand. Could you explain?
  • cnd
    cnd almost 13 years
    You said "it only waits until all resources are loaded" , so I need to slow down this time.
  • Emond
    Emond almost 13 years
    That is when you use the implicit way of showing the Splash Screen. When you use the explicit way you are in control.
  • cnd
    cnd almost 13 years
    But if I changing ApplicationDefinition to Page I have some troubles with MVVM Locator based on it. So I want to trick default method.
  • nikeee
    nikeee over 11 years
    A vad solution that freezes the UI thread. Better use the TAP await TaskEx.Delay(1000)

Related