来自 Visual Studio 的闪屏操作不起作用 (WPF)

Splashscreen-Operation from Visual Studio does not work (WPF)

对于我的 WPF 应用程序,我想向我的项目添加启动画面 ("Project")。因此,我向我的应用程序添加了另一个 WPF-Window(称为 "SplashScreen")并将其在属性 window 中的生成操作更改为 'SplashScreen'。 但是当我尝试构建我的解决方案时,我收到了这些错误消息:

 'Project.SplashScreen' does not contain a constructor that takes 1 arguments (App.g.cs)
 No overload for method 'Show' takes 1 arguments
 The name 'InitializeComponent' does not exist in the current context

这是我的代码 App.g.cs Window:

public static void Main() {
        SplashScreen splashScreen = new SplashScreen("splashscreen.xaml");  (first error message refers to this line)
        splashScreen.Show(true); (second error message to this)
        GVPI_Fernwartung.App app = new GVPI_Fernwartung.App();
        app.InitializeComponent();
        app.Run();
    }

我真的不明白这些错误信息是从哪里来的,因为这段代码是由 Visual Studio 自动生成的。当我将图像添加到我的项目并将其 'Build Action' 更改为 'SplashScreen' 时,我收到相同的错误消息。 有谁知道如何避免这种情况?如果有任何帮助,我将不胜感激!

您应该 将 WPF window 的 Build Action 设置为 SplashScreen。将其设置回 Page

SplashScreen Build Action 应该只用于静态图像:https://msdn.microsoft.com/en-us/library/cc656886(v=vs.110).aspx