I have a 'pile' of expanders on top of each other, which can be opened/closed independently.
All but one have a fixed height (when expanded). The other has a MinHeight
, but I would like it to stretch to fill the remaining available height. If the combined heights of the expanders is greater than the available height, then scrollbars appear.
I've got that far using a Grid
, with one expander per grid, and the row Height
set to *
for the stretching expander, and Auto
for the others.
This works fine except in one case: if the stretchy expander is collapsed, and the combined height of the other expanders is less than the available height, then the stretching expander fills the remaining space anyway, just with it's content collapsed so I get a big blob of background colour.
I've also tried a StackPanel, or nested Grids, but haven't managed to resolve that problem without creating others.
Any ideas?
(Paste this into a Window)
<ScrollViewer>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*" MinHeight="23"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Expander IsExpanded="False" Grid.Row="0" Header="Fixed">
<Border Background="Red" Height="200" />
</Expander>
<Expander IsExpanded="False" Grid.Row="1" Header="Stretchy">
<Border Background="Blue" />
</Expander>
<Expander IsExpanded="False" Grid.Row="2" Header="Fixed">
<Border Background="Green" Height="300" />
</Expander>
</Grid>
</ScrollViewer>