WPF SplashScreen 实现

发布于 2024-08-11 23:06:36 字数 494 浏览 3 评论 0原文

我尝试在 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,那里有什么类以及它必须如何实现。有人可以粘贴一个例子吗?

I try to implement Splash Screnn in WPF. I have found some nice ehample in MSDN, but there is one place:

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();

    });

}

The problem is Helper, whats the class is there and how it must be implemented. Someone could paste an example or smth?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

荭秂 2024-08-18 23:06:36

还有一种更简单的方法:

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

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

There is an even easier way:

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

  1. Add the image file to the WPF Application project. For more information, see How to: Add Existing Items to a Project.
  2. In Solution Explorer, select the image.
  3. In the Properties window, click the drop-down arrow for the Build Action property.
  4. Select SplashScreen from the drop-down list
长安忆 2024-08-18 23:06:36

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

<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);
}

You can use code like this do display an image on startup:

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

in the code behind:

private void Application_Startup(object sender, StartupEventArgs e)
{
    SplashScreen screen = new SplashScreen("Images/splash.bmp");
    screen.Show(true);
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文