2017-04-18 93 views
0

我的WPF应用程序我想添加一个splashscreen到我的项目(“项目”)。因此,我为应用程序添加了另一个WPF窗口(称为“SplashScreen”),并将属性窗口中的Build Action更改为“SplashScreen”。 但是当我尝试建立我的解决方案,我得到这些错误消息:从Visual Studio中的飞溅屏幕操作不起作用(WPF)

'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窗口中的代码:

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自动生成。当我将图像添加到我的项目并将其“构建操作”更改为“SplashScreen”时,我收到相同的错误消息。 有谁知道如何避免这种情况?我会很感激任何帮助!

回答

1

您应该而不是将WPF窗口的Build Action设置为SplashScreen。将其重新设置为Page

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

+0

的事情是我有这个问题,即使静态图像,这是什么最让我感到困惑。但是,在删除我的程序并重新制作所有内容后,它会使用静态图像。我会找到另一种方法使它适用于窗口。 – MaChaToc