I need to put up a png image as splash screen for my WPF.
I imported the file to project and changed Build Action to 'Splash Screen'
This should have done the job, but I am getting this error message:
Unknown build error, 'An item with the same key has already been added.'
Googling the error didn't help.
Follow this steps for adding splash screen into WPF application in Visual Studio: Create or get any image and add it to your project (e.g. inside Images folder): Open properties window for this image (View → Properties Window) and change Build Action setting to SplashScreen value: Run the application.
In the Properties window, click the drop-down arrow for the Build Action property. Select SplashScreen from the drop-down list. Press F5 to build and run the application. The splash screen image appears in the center of the screen, and then fades when the main application window appears. In Solution Explorer, select the splash screen image.
Run the application. You'll see your splash screen image on the center of the screen before application window appears (after window appears, splash screen image will faded out within about 300 milliseconds). If your application is lightweight and simple, it will launch very fast, and with similar speed will appear and disappear splash screen.
You can use any image format that is supported by the Windows Imaging Component (WIC). For example, you can use the BMP, GIF, JPEG, PNG, or TIFF format. Add the image file to the WPF Application project. In Solution Explorer, select the image. In the Properties window, click the drop-down arrow for the Build Action property.
I can confirm that changing the build action to Application Definition and then building (there will be errors), then switching it back to Splash Screen and running the program clears this error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With