这是我希望在WPF应用程序启动时发生的基本事件。 这非常类似于Word在我的计算机上的启动方式。
- 显示忙碌光标。
- 执行基本初始化。 这需要几秒钟时间,并且需要在显示启动画面之前完成。
- 显示启动画面。 此启动画面显示更深入的初始化进度,并可能需要一段时间(从数据库缓存信息)。
- 显示默认光标。 由于启动画面正在显示进度,因此无需显示繁忙光标。
- 启动画面进度条完成后,显示主窗口。
- 关闭启动画面。
除了在启动画面显示之前显示繁忙光标之外,一切正常。 当我通过快捷方式执行应用程序时,等待光标会闪烁,但很快就会回到默认状态。 我尝试了不同的设置光标的方法,但没有一个有效,我认为问题在于我不在控件/窗口中--我是在App.xaml.cs中进行操作的。 而且,我设置的属性似乎是Windows Forms属性。 下面是我的代码摘录:
protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
System.Windows.Forms.Application.UseWaitCursor = true;
//System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor;
//System.Windows.Forms.Application.DoEvents();
Initialize();
SplashWindow splash = new SplashWindow();
splash.Show();
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default;
// Right now I'm showing main window right after splash screen but I will eventually wait until splash screen closes.
MainWindow main = new MainWindow();
main.Show();
}