如何删除WPF中的系统菜单?
根据此 MSDN 页面,如果我使用的是 Window,那么我可以通过将左上角的控制框设置为 false 来禁用它。像这样: this.ControlBox = false;
ControlBox 有最大化、最小化、恢复和关闭选项
但由于我使用 RibbonWindow 而不是 Window,在这种情况下如何禁用控制框?
这个问题非常相关,但我一直希望禁用系统菜单,而不仅仅是为了阻止 Alt+Space。这是因为(我认为)左上角的 SystemMenu 的操作侦听器会阻止我的 XAML 中的可单击 UI 元素。
我应该指出,这对于 Windows Server 2003 来说不是问题,但是当在 Windows 7 中打开应用程序时,SystemMenu/ControlBox 会干扰左上角的 UI 元素。
此外,我发现干扰系统菜单通常会导致应用程序右上角的按钮被停用,但我不希望这种情况发生。
感谢您的链接 Eammonn。我认为那个人试图做的是禁用右上角的 [X] 按钮,而不是左上角的菜单,但我可能是错的。我认为它不起作用的原因是他们使用
According to this MSDN page, if I were using Window, then I could disable the control box in the top left hand corner by setting it to false. Like this: this.ControlBox = false;
The ControlBox has Maximize, Minimize, Restore and Close options
But since I'm using RibbonWindow instead of Window, how would I disable the control box in this situation?
This question is very related, but I'm looking to disable the SystemMenu all the time, not just to prevent the Alt+Space. This is because (I think) the action listener for the SystemMenu in the top left hand corner blocks a clickable UI element in my XAML.
I should note that this is not a problem with Windows Server 2003, but when the application is opened in Windows 7, the SystemMenu/ControlBox interferes with the UI element in the top left corner.
Additionally, I've found that interfering with the system menu usually results in the buttons in the top right hand corner of the application being deactivated, but I don't want that to happen.
Thanks for the link Eammonn. I Think what that person was trying to do is disable the [X] button in the top right hand corner, not the menu in the top left hand corner, but I could be wrong. The reason I don't think it'll work is that they're using <Window x:Class=
and I'm using <dc:RibbonWindow x:Class=
. Does this make a difference?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
WPF 窗口不是 System.Windows.Forms 对象,因此 this.ControlBox = false 无论如何都不起作用。在 wpf 中没有明确的属性可以执行此操作,但请参阅这篇文章
http://winsharp93.wordpress.com/2009/07/21/wpf-hide-the-window-buttons-minimize- Restore-and-close-and-the-icon-of-a-window/
它描述了如何删除 WPF 版本的控件框。
WPF 控件派生自 System.Windows.Controls 而不是 System.Windows.Forms
The WPF window is not a System.Windows.Forms object, so this.ControlBox = false would not work anyway. There is no explicit property to do this in wpf but see this article
http://winsharp93.wordpress.com/2009/07/21/wpf-hide-the-window-buttons-minimize-restore-and-close-and-the-icon-of-a-window/
It describes how you can remove the WPF version of the control box.
WPF controls are derived from System.Windows.Controls and not System.Windows.Forms
你设置你的窗户的
祝你好运。
You set your Window's
Good luck.