WPF-Window Topmost 仅适用于自己的应用程序?
我的 WPF 应用程序中的 Splashscreen/Loading-Window 设置为 Topmost="True"。现在,即使您切换到另一个应用程序,该窗口也会位于所有其他窗口之上(因为加载需要一些时间)。我不想要这种行为。
如果我设置 Topmost="False" 窗口根本不是最上面的。但是,如果您在使用另一个应用程序后切换回我的应用程序,我的客户有时不会意识到加载 Windows 仍在工作。应用程序似乎没有响应,因为后台的加载窗口仍然是活动窗口并且是模式窗口。
我希望将加载窗口放在最上面,但前提是我的应用程序位于前台。如果您切换到另一个程序,该窗口应该会消失,并在您切换回来时重新出现在最上面。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以尝试使用窗口的
Owner
属性,这样启动画面将始终与其他窗口重叠。You can try to use the
Owner
property of the window, with that the splash screen will always overlap the other windows.我认为更改主窗口的加载模式可能会有所帮助。如果您可以将加载窗口的耗时部分放在后台线程上,那么您可以采取以下路径:
在处理负载时,应将飞溅保持在顶部。
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:
that should keep the splash on top while load is being processed.
为了澄清这一点,我将重新回答这个问题:
Martin Moser 的答案是正确的。
将所有者属性设置为:
并将 TopMost 设置为 false。
To clarify I will reanswer this question:
Martin Moser's answer is the correct one.
Set the owner property like:
AND set TopMost to false.