[英]Change duration of splash screen?
我最近在我的WPF应用程序中添加了一个启动画面。我的应用程序加载速度非常快,因此屏幕只有毫秒。我会如何延长启动画面的时间。我希望它是两秒钟。
If you trigger the splash screen to show in the Application.Startup Event you will have full control over it. 如果触发启动屏幕以显示在Application.Startup事件中,您将完全控制它。 (be sure to call .Show() with false) (务必使用false调用.Show())
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. 然后,当您希望关闭启动画面时,可以调用screen.Close()。
You can also call System.Threading.Thread.Sleep() before the InitializeComponent in the main window. 您还可以在主窗口中的InitializeComponent之前调用System.Threading.Thread.Sleep() 。 this works. 这很有效。
something like that: 类似的东西:
public MainWindow()
{
System.Threading.Thread.Sleep(2000);
InitializeComponent();}
The best way and using the API is 最好的方法和使用API是
SplashScreen splash = new SplashScreen("splashscreen.jpg");
splash.Show(false);
splash.Close(TimeSpan.FromMilliseconds(2));
InitializeComponent();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.