我有无边界的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;
}
但尺寸变化分几步执行:左侧位置变化,顶部位置变化,宽度变化和高度变化。如何同时更改所有这些属性?