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.
Related videos on Youtube

Author by
cnd
Updated on June 04, 2022Comments
-
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 almost 13 yearsSplashScreen works automatic with ApplicationDefinition on .net 4
-
Emond almost 13 yearsYes, 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 almost 13 yearsSorry, I do not understand. Could you explain?
-
cnd almost 13 yearsYou said "it only waits until all resources are loaded" , so I need to slow down this time.
-
Emond almost 13 yearsThat is when you use the implicit way of showing the Splash Screen. When you use the explicit way you are in control.
-
cnd almost 13 yearsBut if I changing ApplicationDefinition to Page I have some troubles with MVVM Locator based on it. So I want to trick default method.
-
nikeee over 11 yearsA vad solution that freezes the UI thread. Better use the TAP
await TaskEx.Delay(1000)