最大化窗口时,屏幕的Width
属性似乎没有更新到完全最大化的宽度。如果我调整它的大小,一切正常,但在最大化时却不行。
我的代码如下:
private void Window_SizeChanged(object sender, SizeChangedEventArgs e)
{
UpdateColumns();
}
private void button1_Click(object sender, RoutedEventArgs e)
{
UpdateColumns();
}
private void UpdateColumns()
{
ColumnCount = Math.Round(Width/150);
statusBarItemColumnCount.Content = ColumnCount;
button1.Content = ColumnCount + " " + Width;
}
private void Window_StateChanged(object sender, EventArgs e)
{
UpdateColumns();
}