WPF: SizeToContent = "WidthAndHeight" + WindowState = "Minimized" Bug

When I set the default properties for the window as:

SizeToContent="WidthAndHeight"and WindowState="Minimized",

The right side of the window will be black .

To play it, try creating a new WPF project and set the properties as described above, then add the following:

<StackPanel>
    <Button>HELLO</Button>
    <Button>HELLO</Button>
</StackPanel>

When you run it, it will look like this:

enter image description here

But in design mode, it looks great.

enter image description here

If you try to resize the window, the buttons will snap to places and fix the layout. Or, if you delete one of the two properties, the black part will disappear.

Is there any work for this? Is this a known bug?

+4
source share
2

, . , . :

protected override void OnStateChanged(EventArgs e)
{
    base.OnStateChanged(e);

    InvalidateMeasure();
}

WPF , , .

+3

, , .

WPF , , WPF. , , .

. WPF. .

+3

All Articles