在加载所有应用程序数据后,需要在关闭启动画面后打开主窗口。
它给出了错误
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
DispatcherHelper.Initialize();
Global = new AARFID.KeyManagement.UI.Properties.Settings();
Splash splash = new Splash();
var isClosed = splash.ShowDialog();
if (isClosed == true)
{
splash.Close();
}
UI.Main m = new UI.Main();
m.Show();
}
答案 0 :(得分:0)
我更喜欢在不同的线程中打开启动画面。
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
Thread t = new Thread(new ThreadStart(SplashStart));
t.Start();
Thread.Sleep(1500);
InitializeComponent();
t.Abort();
Form1.Activate();
}
public void SplashStart()
{
Application.Run(new SplashScreen());
}
}
}
这是我的工作代码。你可以尝试这个解决方案。
答案 1 :(得分:0)
我使用Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
DispatcherHelper.Initialize();
Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
Global = new Properties.Settings();
Splash splash = new Splash();
var isClosed = splash.ShowDialog();
Current.ShutdownMode = ShutdownMode.OnMainWindowClose;
if (isClosed == true)
{
var main = new UI.Main();
this.MainWindow = main;
this.MainWindow.Show();
}
}