How to add a scroll bar to the expander panel?

I have a stack pane inside the expander pane that I add programmatically. Currently, the exanpander stops at the bottom of the form, but the stack panel continues to grow. I would like the stack panel to be limited by the expander and scroll to display the checkboxes. Do I need to check the boxes in the list box to get 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> 

");

+3
source share
2 answers

You can nest a 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> 
+8
source

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

+2
source

All Articles