WPF SplashScreen , how to make splashscreen showing longer

后端 未结 4 1765
梦如初夏
梦如初夏 2021-01-22 09:38

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 ApplicationDefin

相关标签:
4条回答
  • 2021-01-22 09:50

    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.

    0 讨论(0)
  • 2021-01-22 10:00

    Another approach is to find the App.g.cs file and its Main():

           public static void Main() {
                SplashScreen splashScreen = new SplashScreen("splash.jpg");
                splashScreen.Show(true);
                Thread.Sleep(3000);           
                someNameSpace.App app = new someNameSpace.App();
                app.Run();
           }
    

    Where the only newly added field is Thread.Sleep(3000);, which will delay the showing of the splash screen by 3 seconds.

    0 讨论(0)
  • 2021-01-22 10:11

    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.

    0 讨论(0)
  • 2021-01-22 10:16

    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);
        }
    }
    
    0 讨论(0)
提交回复
热议问题