WPF SplashScreen实现

时间:2009-11-16 12:33:36

标签: wpf splash-screen

我尝试在WPF中实现Splash Screnn。我在MSDN中找到了一些很好的例子,但有一个地方:

private void _applicationInitialize(SplashScreen splashWindow)
{

    Thread.Sleep(1000);

    // Create the main window, but on the UI thread.

    Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Invoker)delegate
    {

        Window1 MainWindow = new Window1();

        Helper.setWin(MainWindow);

        MainWindow.Show();

    });

}

问题是 Helper ,类是什么以及必须如何实现。有人可以粘贴一个例子或smth吗?

2 个答案:

答案 0 :(得分:12)

有一种更简单的方法:

http://msdn.microsoft.com/en-us/library/cc656886.aspx

  
      
  1. 将图像文件添加到WPF应用程序项目。有关更多信息,请参见如何:将现有项添加到项目。
  2.   
  3. 在解决方案资源管理器中,选择图像。
  4.   
  5. 在“属性”窗口中,单击“构建操作”属性的下拉箭头。
  6.   
  7. 从下拉列表中选择SplashScreen
  8.   

答案 1 :(得分:6)

您可以使用这样的代码在启动时显示图像:

<Application
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml" Startup="Application_Startup">

在后面的代码中:

private void Application_Startup(object sender, StartupEventArgs e)
{
    SplashScreen screen = new SplashScreen("Images/splash.bmp");
    screen.Show(true);
}
相关问题