Search code examples
c#wpfvisual-studio-2013splash-screen

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


for my WPF-Application I'd like to add a splashscreen to my Project ("Project"). Therefore I added another WPF-Window to my application (called it "SplashScreen") and changed its Build Action in the properties window to 'SplashScreen'. But when I try to build my solution I get those error messages:

 '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

That is the code in my 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();
    }

I don't really understand where those error messages come from, as this code was generated automatically by Visual Studio. When I add an image to my project and change its 'Build Action' to 'SplashScreen' I get the same error messages. Does anyone know how to avoid this? I'd appreciate any help!


Solution

  • You should not set the Build Action of a WPF window to SplashScreen. Set it back to Page.

    The SplashScreen Build Action should only be used for static images: https://msdn.microsoft.com/en-us/library/cc656886(v=vs.110).aspx