tags:

views:

1348

answers:

2

I have a stack panel inside of an expander panel that I programaticaly adds check boxes to. Currently the exanpander stops at the bottom of the form, but the stack panel keeps growing. I would like the stack panel to be bounded by the expander and scroll to display the check boxes. Do I need house the check boxes in a list box to get the scroll functionality?

<Grid>
    <Expander Header="Expander1"  Margin="0,0,0,2" Name="Expander1" VerticalAlignment="Top" Background="Coral">
        <StackPanel Name="StackScroll" Margin="0,0,0,2"  Background="Aqua"></StackPanel>
    </Expander>
</Grid>

");

+2  A: 

Set ScrollViewer.VerticalScrollBarVisibility="Auto" in your StackPanel declaration.

Pete OHanlon
+5  A: 

You can nest the StackPanel in a ScrollViewer:

  <Grid>  
    <Expander Header="Expander1"  Margin="0,0,0,2" Name="Expander1" VerticalAlignment="Top" Background="Coral">
      <ScrollViewer VerticalScrollBarVisibility="Auto">
        <StackPanel Name="StackScroll" Margin="0,0,0,2"  Background="Aqua">
        </StackPanel>
      </ScrollViewer>
    </Expander>
  </Grid>
Guy Starbuck
You could, but the VerticalScrollBarVisibility is an attached property that you can set directly on the StackPanel.
Pete OHanlon