views:

71

answers:

2

I have a StackPanel with several CheckBox controls inside it. How do I prevent the StackPanel from shrinking and obscuring the CheckBox controls when the window is resized?

    <StackPanel Margin="12,89,12,62" Name="stackPanel1">
        <CheckBox Name="chkOption1" Width="157" IsChecked="True" Margin="6">Do this thing</CheckBox>
        <CheckBox Name="chkOption2" Width="157" IsChecked="True" Margin="6">Do another thing</CheckBox>
        <CheckBox Name="chkOption2" Width="157" Margin="6">Do a third thing</CheckBox>
        <Button Height="23" Name="btnRunOperations" Click="btnRunOperations_Click" Margin="3">Do Selected Things</Button>
    </StackPanel>

EDIT: Does WPF have a different container control that has this behavior "out of the box"? This seems like a really common scenario.

A: 

Well, I guess you could set the MinimumHeight of the stackpanel to an appropriate value, either hardcoded, either calculated as the sum of the heights of all elements within.

luvieere
A: 

you could use a binding and a custom converter where the converter calculates the value for you.

<StackPanel Height="{Binding Converter=MyConverter}"/>
Muad'Dib