Search code examples
c#wpfwindowmaximize

disable maximize capacity in a wpf window


I'm trying to disable the maximize capacity (not the maximize button) in a wpf window, but so far nothing has succeded.

I'm using a window with WindowStyle="none", but when I drag the window to the far top of the screen, the OS "maximizes" the window (terribly bad, by the way).

I uploaded 3 pictures to show what is happening exactly.

(however, due to the fact that I don't have 10 reputation, I have to post the links instead. Sorry about that. And I can't put all 3 links, only 2 of them, but the first one is just of the window working normally)

During: http://i58.tinypic.com/243lr89.jpg

After: http://i62.tinypic.com/f3c1mu.jpg


Solution

  • use the window state change event:

    private void Window_StateChanged(object sender, EventArgs e)
    {
        if (this.WindowState == System.Windows.WindowState.Maximized) 
        {
            this.WindowState = System.Windows.WindowState.Normal; 
        }
    }