我最近在我的WPF应用程序中添加了一个启动画面。我的应用程序加载速度非常快,因此屏幕只有毫秒。我会如何延长启动画面的时间。我希望它是两秒钟。
If you trigger the splash screen to show in the Application.Startup Event you will have full control over it. (be sure to call .Show() with false)
private void Application_Startup(object sender, StartupEventArgs e)
{
SplashScreen screen = new SplashScreen("splashScreen.png");
screen.Show(false);
}
Then you can call screen.Close() when you would like the splash screen to close.
You can also call System.Threading.Thread.Sleep() before the InitializeComponent in the main window. this works.
something like that:
public MainWindow()
{
System.Threading.Thread.Sleep(2000);
InitializeComponent();}
The best way and using the API is
SplashScreen splash = new SplashScreen("splashscreen.jpg");
splash.Show(false);
splash.Close(TimeSpan.FromMilliseconds(2));
InitializeComponent();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.