我有一个WPF应用程序,可以选择性地接受命令行参数。其中一个参数指定“静默模式”(无UI)。基于此参数,如何禁用启动时的闪屏呈现?
我有一个WPF应用程序,可以选择性地接受命令行参数。其中一个参数指定“静默模式”(无UI)。基于此参数,如何禁用启动时的闪屏呈现?
您需要将启动画面图片的 Build Action 设置为 Resource 而不是 SplashScreen。
例如:
private void OnStartUp(Object sender, StartupEventArgs e)
{
if (ShowSplashScreenArgument)
{
SplashScreen splashScreen = new SplashScreen("YourSplashScreen.bmp");
splashScreen.Show();
}
// Do loading code here..
MainWindow mainWindow = new MainWindow();
if (ShowSplashScreenArgument)
{
// Close the splash..
splashScreen.Close();
}
mainWindow.Show();
}