窗口大小调整时,WPF会同时更改属性

时间:2014-07-23 06:03:11

标签: c# wpf forms properties window-resize

我有无边界的WPF窗口(WindowStyle == None)以及下面的手动表单最大化/恢复代码:

var currentScreen = this.CurrentScreen();
if (windowState == System.Windows.WindowState.Normal)
{
    windowState = System.Windows.WindowState.Maximized;
    left = Left;
    top = Top;
    width = Width;
    height = Height;
    Left = currentScreen.WorkingArea.Left;
    Top = currentScreen.WorkingArea.Top;
    Width = currentScreen.WorkingArea.Width;
    Height = currentScreen.WorkingArea.Height;
}
else
{
    windowState = System.Windows.WindowState.Normal;
    Left = left;
    Top = top;
    Width = width;
    Height = height;
}

但尺寸变化分几步执行:左侧位置变化,顶部位置变化,宽度变化和高度变化。如何同时更改所有这些属性?

0 个答案:

没有答案