Disable maximize button of WPF window, keeping resizing feature intact Disable maximize button of WPF window, keeping resizing feature intact wpf wpf

Disable maximize button of WPF window, keeping resizing feature intact


Disabled only Maximize:

ResizeMode="CanMinimize"


WPF does not have the native capability to disable the Maximize button alone, as you can do with WinForms. You will need to resort to a WinAPI call. It's not scary:

[DllImport("user32.dll")]private static extern int GetWindowLong(IntPtr hWnd, int nIndex);[DllImport("user32.dll")]private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);private const int GWL_STYLE = -16;private const int WS_MAXIMIZEBOX = 0x10000;private void Window_SourceInitialized(object sender, EventArgs e){    var hwnd = new WindowInteropHelper((Window)sender).Handle;    var value = GetWindowLong(hwnd, GWL_STYLE);    SetWindowLong(hwnd, GWL_STYLE, (int)(value & ~WS_MAXIMIZEBOX));}


If you set

WindowStyle="ToolWindow"

In your window's properties, it will give you a resizable window with no minimize or maximize buttons at the top. It'll be square looking and the close button is also square, but at least minimize and maximize aren't there!