How to disable maximizing of a window when the win

2019-07-18 23:41发布

问题:

I have a windows which hasResizeMode="CanResizeWithGrip" and AllowTransparency="true" set. It works fine until it is moved to the top of the screen when it is then automatically Maximized.

How can stop it maximizing so I can display the screen as a window positioned at the top of the screen.

回答1:

Try:

private void Window_LocationChanged(object sender, EventArgs e)
{
    this.WindowState = System.windows.WindowState.Normal;
}

If you have to be specific, check for your location:

    if (this.Top == 0)
    {
        this.WindowState = System.windows.WindowState.Normal;
    }