Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you add a scroll bar to an expander panel?

Tags:

wpf

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>

");

like image 948
user38349 Avatar asked Dec 09 '22 22:12

user38349


1 Answers

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>
like image 55
Guy Starbuck Avatar answered Jan 02 '23 08:01

Guy Starbuck