Simple WPF App Splash Screen "Jumps" at startup

Viewed 752

My WPF app shows a PNG image as a splash screen at startup using the standard MS recommended method. That is, I chose an existing image file and set its build action to "Splash Screen" I like this because it's simple. No code to write, just a property.

But it's got a problem: It "jumps".

When my app is starting and the splash screen first appears it is large and centered on the screen as I want. But then, almost immediately, it jumps up to the left and gets smaller. As if its window goes from being maximized to only taking up part of the screen.

This "jump" happens even before the constructor of my Application object is reached so certainly long before my MainWindow is in mix. And I'm certainly not resizing anything.

So what could be causing this? I can't even see that I can set a breakpoint anywhere to detect this. Is there some property I can set somewhere to prevent this from happening? Like maybe in my App.xaml?

I should say that this is a Prism 7.2 application using .NET core 3.1, if any of that matters

1 Answers

If you override the:

protected virtual void OnStartup (System.Windows.StartupEventArgs e);

what you probably already do. Then you can control the splash screen a little bit more in there by:

SplashScreen splashScreen = new SplashScreen(YourImageFileName);
splashScreen.Show(false, true); // Auto-close: NO, On top: YES

And then later when you main window is ready to be shown, then:

splashScreen.Close(FadeTimeout); // FadeTimeout is of type TimeSpan

I know you liked the way, where you do not have anything in your code on the splash screen, but this little extra code you can control the splash screen much more. And it is probably what you need

Related