Reputation: 6552
When I set the default properties of the window as:
SizeToContent="WidthAndHeight"
and WindowState="Minimized"
,
The window will have a black part on the right side.
To reproduce it try making a new WPF project and set the properties as stated above then add this:
<StackPanel>
<Button>HELLO</Button>
<Button>HELLO</Button>
</StackPanel>
When you run it, it will look like this...
But in design mode, it looks fine..
If you try to resize the window, the buttons will snap into places and fix the layout. Or if you remove the either of the two properties, the black part will be gone.
Is there any work around for this? Is this a known bug?
Upvotes: 5
Views: 1537
Reputation: 70701
As noted in Chris' answer, this is a known bug. It is simple to work-around though. Just add the following override to your window class:
protected override void OnStateChanged(EventArgs e)
{
base.OnStateChanged(e);
InvalidateMeasure();
}
This will force WPF to redo the layout for the window when the window state changes, giving the correct results.
Upvotes: 4
Reputation: 1294
It appears as though this is a known issue that they won't fix.
The WPF team has recently reviewed this issue and will not be addressing this issue as at this time the team is focusing on the bugs impacting the highest number of WPF developers. If you believe that this was resolved in error, please reactivate this bug with any necessary supporting details.
We appreciate the feedback. However, this issue will not be addressed in the next version of WPF. Thank you.
Upvotes: 3