Question

The Width property of the screen doesn't seem to update to the fully maximized width when maximizing a window. If I resize it everything works fine, but not when maximizing.

The code I have is as follows:

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();
}
Was it helpful?

Solution

Take a look at ActualWidth, rather than Width.

OTHER TIPS

try using ActualWidth instead of Width, that should fix it

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top