WPF 窗口和消息框在顶部打开
如何使窗口和消息框在屏幕顶部打开但不保持这种状态? Topmost 属性在这里不起作用,因为它使窗口始终位于顶部,而我只需要它在顶部打开。问题是,当 topmost = false 时,我们的窗口和消息框有时会不在屏幕顶部打开,这会让用户感到不舒服。有什么想法吗?
How can i make the window and the messagebox be opened at the top of the screen but not to keep this state? Topmost property doesn't work here, because it makes the window to be always at the top, and i need it only to be opened at the top. The problem is that when the topmost = false, our windows and messageboxes are opened not at the top of the screen sometimes, which can make users uncomfortable. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否在寻找
Window.Activate
?这是引起用户注意的窗口的首选机制。请注意,它带有限制。
Are you looking for
Window.Activate
? This is the preferred mechanism for bringing your window to the attention of the user.Be aware that it comes with restrictions.
创建窗口时尝试使用
window.Owner = owner 或 Window.GetWindow(this)
并查看窗口是否位于顶部
while createing windows try with
window.Owner = owner or Window.GetWindow(this)
and see whether windows coming on top
最简单的方法:使用 MessageBoxOptions.DefaultDesktopOnly 将 MessageBox 保持在窗口顶部。
Simplest catch: using MessageBoxOptions.DefaultDesktopOnly keeps the MessageBox on top of the window.