Reputation: 73
I have a grid that further down have a StackPanel. I have defined the row's height for the last to be "*", and in this very last row, is where the StackPanel and all the control would inhabit.
So I have the bellow code in XAML for my StackPanel
<StackPanel Grid.Row="1" MaxHeight="333">
<StackPanel MaxHeight="333">
<ScrollViewer MaxHeight="333">
<TextBlock x:Name="lblRouteDetail" FontSize="35" TextWrapping="Wrap"/>
</ScrollViewer>
</StackPanel>
</StackPanel>
Well, it worked, only that I have to constraint that the MaxHeight is 333, without that, it won't work; the ScrollViewer won't work, the content in the TextBlock wouldn't be scrollable.
Could you state where is my problem, and how to fix this things up?
Upvotes: 0
Views: 697
Reputation: 25201
A StackPanel
, unless set to a specific height (or width if its orientation is set to Horizontal
), does not constrain the height of its children, but is sized according to them. If you want to scroll your controls, you could either keep the MaxHeight
property or use a different panel for holding them, such as a Grid
or a DockPanel
.
Upvotes: 2