In the example below I cannot get the ScrollViewer to fill the space available, The height is unknown due to the dynamic content above but is there no way it can fill the space available instead of over running?
<Grid x:Name="Main" Height="200" MaxHeight="200">
<StackPanel>
<Grid x:Name="MainContent" Height="170" MaxHeight="170">
<StackPanel>
<TextBlock FontSize="24" Text="Dynamic data "/>
<TextBlock FontSize="24" Text="height "/>
<TextBlock FontSize="24" Text="unknown... "/>
<Grid x:Name="Results" Background="Red">
<ScrollViewer>
<StackPanel>
<TextBlock FontSize="24" Text="Result set... 0"/>
<TextBlock FontSize="24" Text="Result set... 1"/>
<TextBlock FontSize="24" Text="Result set... 2"/>
<TextBlock FontSize="24" Text="Result set... 3"/>
</StackPanel>
</ScrollViewer>
</Grid>
</StackPanel>
</Grid>
<Grid x:Name="Nav">
<Button HorizontalAlignment="Left" Content="Back"/>
<Button HorizontalAlignment="Right" Content="Forward"/>
</Grid>
</StackPanel>
</Grid>
in MainContent
Grid
use DockPanel
instead of StackPanel
with LastChildFill=True
, something like this:
<Grid x:Name="MainContent" Height="170" MaxHeight="170">
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Top" FontSize="24" Text="Dynamic data "/>
<TextBlock DockPanel.Dock="Top" FontSize="24" Text="height "/>
<TextBlock DockPanel.Dock="Top" FontSize="24" Text="unknown... "/>
<Grid x:Name="Results" Background="Red">
<ScrollViewer>
<StackPanel>
<TextBlock FontSize="24" Text="Result set... 0"/>
<TextBlock FontSize="24" Text="Result set... 1"/>
<TextBlock FontSize="24" Text="Result set... 2"/>
<TextBlock FontSize="24" Text="Result set... 3"/>
</StackPanel>
</ScrollViewer>
</Grid>
</DockPanel>
</Grid>
then last element of DockPanel
will adjust itself to available space
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With