I'm trying to hide/remove the close button on my MahApps MetroWindow without success.
I've tried with this code:
private const int GWL_STYLE = -16;
private const int WS_SYSMENU = 0x80000;
[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 void Window_Loaded(object sender, RoutedEventArgs e)
{
var hwnd = new WindowInteropHelper(this).Handle;
SetWindowLong(hwnd, GWL_STYLE, GetWindowLong(hwnd, GWL_STYLE) & ~WS_SYSMENU);
}
I've also set up some properties:
...ShowTitleBar="False" WindowStyle="None" ResizeMode="NoResize"
Loaded="Window_Loaded" ...
So the Window_Loaded is trigger correctly but the code of this question seems not working.
This is the actual result:
Why the button don't disappear? What I'm doing wrong?