Reputation: 27095
I have a seemingly simple layout problem in Windows Phone. The problem is illustrated in the image below:
My requirements are as follows:
When I use a StackPanel
or auto-height Grid
rows, the box will overflow. If I try star height rows
I can't control a large title.
Upvotes: 3
Views: 148
Reputation: 27095
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<TextBlock ...>Title</TextBlock>
<TextBlock Grid.Row="1" ...>SubTitle</TextBlock>
</Grid>
Found the solution, this will cover everything except the bottom element overflowing the whole screen, in my case this won't be possible. It only works if the parent container does not have infinite height provided (like a StackPanel
).
Basically, auto
height takes 'precedence' over star
-height elements. This gives the bottom TextBlock
room to choose its height, and then assigns the remaining available space to the top element.
Upvotes: 1