WPF does not have a native way to disable maximizing windows (unlike WinForms). Hence consider the following key points:
1. Hide the Maximize button
Using WinAPI is a way to go, but only for hiding the Maximize button. Use the following:
[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));
}
2. Handling maximizing manually
That code above still allows maximizing (e.g. by double click on the window's title).
WPF has no control on the title bar behavior. if you want to change the double click behavior you will need to remove the title bar and create you own. Take a look how it's been done in MahApps.Metro - link to sample. After that handle double click event.