#916 – Scrolling Content within an Expander Control

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"    >
                    <TextBlock Text="Ulysses"/>
                    <!-- bunch more items go here -->
        <TextBlock Text="I'm below the Expander"/>

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"