tags:

views:

15

answers:

1

I have a groupbox that contains nested stack panels that aren't filling in the groupbox entirely. I would like to have all the stackpanels evenly spaced out filling in the entire groupbox. I have attempted changing the VerticalContentAlignment to Stretch for the groupbox, but that does not work.

<GroupBox>
        <StackPanel>
            <StackPanel Orientation="Horizontal">
                <Label Content="Test1" />
                <Label Content="Test2"/>        
            </StackPanel>

            <StackPanel Orientation="Horizontal">
                <Label Content="Test3" />
                <Label Content="Test4"/>
            </StackPanel>
        </StackPanel>
</GroupBox
+1  A: 

StackPanels by default only use as much space as is required to display whatever they contain. If you need different behavior you either need to roll your own version of a stackpanel or use another container. Both Grids/Dockpanels work fine as substitutes.

mdm20