Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF-Window Topmost for own application only?

The Splashscreen/Loading-Window in my WPF application is set to Topmost="True". Now this windows in on top of all other windows even when you switch to another application (because loading will take some time). I don't want this kind of behavior.

If I set Topmost="False" the window in not topmost at all. But If you switch back to my application after working with with another application my customers sometimes don't realize the Loading-Windows is still working. The application appears to be unresponsive because the Loading-Window in the background is still the active window and it is modal.

I want to have the Loading-Window topmost but only if my application is in foreground. If you switch to another program the window should disappear and reappear topmost when you switch back.

like image 699
TalkingCode Avatar asked Mar 17 '10 14:03

TalkingCode


2 Answers

You can try to use the "Owner" property of the window, with that the splash screen will always overlap the other windows.

like image 127
Martin Moser Avatar answered Sep 24 '22 19:09

Martin Moser


I think maybe a change in the loading pattern of your MainWindow might help. If you can put to time consuming part of loading the window on a background thread then you can take this path:

  1. Show MainWindow empty or bare bones (empty fields/grid etc)
  2. Launch async load method to get data and populate main window
  3. Create splash screen, set owner to self and show
  4. make sure to close splash screen when load is complete.

that should keep the splash on top while load is being processed.

like image 29
TheZenker Avatar answered Sep 22 '22 19:09

TheZenker