我目前正在用c#wpf用自定义窗口编写程序。所以,因为必须有一个自定义最大化状态,我想要在没有任务栏的情况下获取屏幕的高度和宽度。 systemparamters.workarea属性似乎是要走的路,但是它赋予我的价值观是错误的。此外,将此设置为新的Maxheight和Maxwidth会设置某种边距,以便在应用程序的右侧和底部有一个小间隙,即使我明确指出this.left = 0且this.left = 0。system.workareaproperty给出错误的值
有人有过这方面的经验吗?
更新:请求的代码(当用户点击最大化按钮时运行(本质上是在最大化和正常之间切换))在我的设计器窗口中没有边距或最大高度/宽度,一切都设置为自动。
private void MaxThis(object sender, System.Windows.RoutedEventArgs e)
{ if (WindowState == WindowState.Maximized){
WindowState = WindowState.Normal;
}
else {
this.MaxWidth = SystemParameters.WorkArea.Width;
this.MaxHeight = SystemParameters.WorkArea.Height;
this.WindowState = WindowState.Maximized;
this.Top = 0;
this.Left = 0;
}
}
更新:我在Blend做了一个新的空白WPF应用程序,添加一个按钮和链接此代码它。右边和底部有相同的边距...
重现问题的邮政编码。 – 2010-07-31 00:25:53