WPF SplashScreen实现

WPF SplashScreen实现,wpf,splash-screen,Wpf,Splash Screen,我尝试在WPF中实现Splash Screnn。我在MSDN中找到了一些不错的eSample,但有一个地方: private void _applicationInitialize(SplashScreen splashWindow) { Thread.Sleep(1000); // Create the main window, but on the UI thread. Dispatcher.BeginInvoke(DispatcherPriority.Norm

我尝试在WPF中实现Splash Screnn。我在MSDN中找到了一些不错的eSample,但有一个地方:

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?

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

<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">

还有一个更简单的方法:

  • 将映像文件添加到WPF应用程序项目。有关详细信息,请参见如何:将现有项添加到项目
  • 在解决方案资源管理器中,选择图像
  • 在“属性”窗口中,单击“生成操作”属性的下拉箭头
  • 从下拉列表中选择SplashScreen

  • YOUR示例显示了一个启动屏幕并使其保持打开状态。实际上,启动屏幕必须在mainWindow之前显示,并且必须在mainWindow出现之前自动关闭。show方法上的布尔值命名为autoclose。这允许WPF在主窗口加载事件中自动处理关闭启动屏幕。也许yuo可以粘贴yuo或启动屏幕窗口代码?这可能更容易理解。它是一个标准的wpf类:System.Windows.splashscreen我不在代码中的任何其他地方引用splashscreen,这就是它的全部内容。你错过了最后一步:4。从下拉列表中选择SplashScreen。这个答案非常好,尤其适合初学者。谢天谢地。
    private void Application_Startup(object sender, StartupEventArgs e)
    {
        SplashScreen screen = new SplashScreen("Images/splash.bmp");
        screen.Show(true);
    }