Jeffrey Greenham Jeffrey Greenham - 26 days ago 6
C# Question

How to remove the System Menu in WPF?

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
I want to disable this box in my own application

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?

Answer

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