When the SplashScreen closes (either manually or by AutoClose), it steals the focus of the MainWindow during the fade-out animation. This results in the caption of the main window switching from active to inactive (grey) to active. Is there any trick to keep the SplashScreen from stealing focus?
When the SplashScreen closes (either manually or by AutoClose), it steals the focus of
Share
Tell the SplashScreen that MainWindow is its parent window. When a child window loses focus, its parent gets the focus. If there is no parent, the window manager decides.splashScreen.Show(mainWindow);
EDIT:
I just found out that there’s a SplashScreen class. Looks like you use that class and not just a normal Form as I assumed.
So, I just made a simple WPF app with a SplashScreen and for me the mentioned effect didn’t happen. The main window didn’t lose focus.
I would suggest you to comment potions of your app’s initalization code out until the flashing stops. Then you have a starting point for more research why the focus is lost.
EDIT2:
Without knowing your code I tried to reproduce the phenomenon and it wasn’t too hard. Whatever I tried, the focus change always happened when the main window was already shown and had focus.
So the best solution I see is to manually show the main window after calling the splash screen’s Close() method:
Remove the StartupUri from App.xaml
Show the SplashScreen after starting the app and initializing ressources. After a (currently fixed) delay close the SplashScreen and show the main window: