当窗口最大化时,它有一个偏移量

时间:2017-11-05 11:33:02

标签: c# wpf

screenshot

红线是桌面,窗口位置左侧偏移7px,顶部偏移7px。如何将窗口向右移动7px并向下移动7px?

我在XAML中设置窗口的最大宽度和高度:

    MaxWidth = "{Binding Source={x:Static SystemParameters.WorkArea}, Path=Width}"
    MaxHeight = "{Binding Source={x:Static SystemParameters.WorkArea}, Path=Height}"

编辑:

    private void BTN_Maximize_MouseUp(object sender, MouseButtonEventArgs e)
    {
        if (IsMaximized)
        {
            WindowState = WindowState.Normal;
        }
        else
        {
            WindowState = WindowState.Maximized;
        }
    }
    bool IsMaximized
    {
        get
        {
            if (WindowState == WindowState.Maximized)
                return true;
            else
                return false;
        }
    }

0 个答案:

没有答案