I'd like to know how to disable the Minimize button, but keep the Maximize/Restore button and the Close button (the red "X").
Here's an image of what I want my window's buttons on the top-right to look like:
You may need to use PInvoke here. Basically you're importing SetWindowLong and GetWindowLong functions and setting corresponding flags to Win API window using it's handle(hwnd)
private const int GWL_STYLE = -16;
private const int WS_MINIMIZE = -131073;
[DllImport("user32.dll", SetLastError = true)]
private static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
private static void CanMinimize(Window w)
{
var hwnd = new WindowInteropHelper(w).Handle;
long value = GetWindowLong(hwnd, GWL_STYLE);
SetWindowLong(hwnd, GWL_STYLE, (int)(value & ~WS_MINIMIZE));
}
Blablablaster is basically right -- you need to P/Invoke a couple of Windows API calls -- but the following TechNet article also describes when/where you should make the call to the Windows API:
WPF: Disabling or Hiding the Minimize, Maximize or Close Button Of a Window
Hope this helps.
I don't think WPF provides a way to disable just the minimize button. What you can do is disable the complete title bar and create a custom title bar for yourself. Check this out.
Here is how I do it
Private Sub WindowAddChange_StateChanged(sender As Object, e As EventArgs) Handles Me.StateChanged
If sender.windowstate = WindowState.Minimized Then
Me.WindowState = WindowState.Normal
End If
End Sub