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.
我的WPF应用程序中的Splashscreen / Loading-Window设置为Topmost =“True”。现在这个窗口在所有其他窗口的顶部,即使你切换到另一个应用程序(因为加载将需要一些时间)。我不想要这种行为。
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.
如果我将Topmost =“False”设置为不在最顶层的窗口。但是如果您在使用其他应用程序后切换回我的应用程序,我的客户有时也不会意识到Loading-Windows仍在运行。应用程序似乎没有响应,因为后台的加载窗口仍然是活动窗口,它是模态的。
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.
我希望装载窗口位于最顶层,但前提是我的应用程序位于前台。如果切换到另一个程序,窗口应该消失,并在切换回时最重新出现。
2 个解决方案
#1
10
You can try to use the "Owner" property of the window, with that the splash screen will always overlap the other windows.
您可以尝试使用窗口的“所有者”属性,因为启动屏幕将始终与其他窗口重叠。
#2
2
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:
我想也许你的MainWindow加载模式的改变可能会有所帮助。如果你可以花时间在后台线程上加载窗口,那么你可以采用这条路径:
- Show MainWindow empty or bare bones (empty fields/grid etc)
- 显示MainWindow空或裸骨(空字段/网格等)
- Launch async load method to get data and populate main window
- 启动异步加载方法以获取数据并填充主窗口
- Create splash screen, set owner to self and show
- 创建启动画面,将所有者设置为自我并显示
- make sure to close splash screen when load is complete.
- 确保在加载完成后关闭闪屏。
that should keep the splash on top while load is being processed.
这应该在处理负载时保持顶部的飞溅。
#1
10
You can try to use the "Owner" property of the window, with that the splash screen will always overlap the other windows.
您可以尝试使用窗口的“所有者”属性,因为启动屏幕将始终与其他窗口重叠。
#2
2
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:
我想也许你的MainWindow加载模式的改变可能会有所帮助。如果你可以花时间在后台线程上加载窗口,那么你可以采用这条路径:
- Show MainWindow empty or bare bones (empty fields/grid etc)
- 显示MainWindow空或裸骨(空字段/网格等)
- Launch async load method to get data and populate main window
- 启动异步加载方法以获取数据并填充主窗口
- Create splash screen, set owner to self and show
- 创建启动画面,将所有者设置为自我并显示
- make sure to close splash screen when load is complete.
- 确保在加载完成后关闭闪屏。
that should keep the splash on top while load is being processed.
这应该在处理负载时保持顶部的飞溅。