I have a multiple treeviews inside expanders, which can grow in height along with the content. But when the height gets larger than the window's size, it goes outside the window.
The obvious solution would be to set the MaxHeight of the Treeview, but I can't determine it easily, because the available height depends on
- Window height
- The other expanders (open/closed)
What do I need to change to make the treeview's height still grow automaticly, but never larger than the window's height?
<StackPanel CanVerticallyScroll="True" ClipToBounds="False" Height="Auto" Name="StackPanel2" Width="250" DockPanel.Dock="Left" Orientation="Vertical" VerticalAlignment="Top" CanHorizontallyScroll="False" Margin="5">
<Border BorderThickness="0" CornerRadius="5" Padding="1" BorderBrush="Red" Margin="0,5" >
<Expander Header="Expander3" Height="Auto" IsExpanded="False" Width="Auto" Margin="2" BorderThickness="1">
<Grid Height="Auto" Width="Auto" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
<TreeView Height="Auto" BorderThickness="1" Margin="0,0,0,0" Padding="7" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
</TreeView>
</Grid>
</Expander>
</Border>
</StackPanel>