#916 – Scrolling Content within an Expander Control
September 27, 2013 1 Comment
The content of an Expander is shown when the control is expanded. If you want to be able to scroll the contents of the Expander, you can set its content to a ScrollViewer, as shown below.
<StackPanel Margin="5"> <Expander BorderBrush="DarkGray" Header="Expand Me" > <ScrollViewer> <StackPanel> <TextBlock Text="Ulysses"/> <!-- bunch more items go here --> </StackPanel> </ScrollViewer> </Expander> <TextBlock Text="I'm below the Expander"/> </StackPanel>
The problem with this is that the Expander will normally expand to fit its content.
To be able to scroll the content of the Expander, you need to constrain its height. You can do this by setting the MaxHeight property.
<Expander BorderBrush="DarkGray" Header="Expand Me" MaxHeight="150">
Pingback: Dew Drop – September 27, 2013 (#1,633) | Morning Dew