I have the following Grid setup in a WPF application.
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="220" />
<RowDefinition Height="40" />
<RowDefinition Height="80" />
<RowDefinition Height="180*" />
</Grid.RowDefinitions>
<!-- some content -->
</Grid>
What I want is for the final row to take up as much height as available in its parent. But it does not seem to honor my '*' command in the final row definition.
Please note that I want all other row heights to be fixed..
Is this possible? If so how? Any help or pointers are appreciated..
place height="*" in last row.
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="220" />
<RowDefinition Height="40" />
<RowDefinition Height="80" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
What you have written should be fine (though as @Bolu commented, the 180*
could be replaced with *
in this case). If the content in the last row is not expanding to fill the available size, I would suspect one of the following:
The Grid
may be nested somewhere below a layout panel that does not arrange its children to fill all available vertical space. For example, is one of the Grid
panel's ancestors a StackPanel
? A good way to test whether this is the culprit is to comment out the entire Grid
and replace it with a Border
with an easily distinguishable background (e.g., Magenta
) and see if it occupies the entire area you expect the Grid
to fill.
There may not actually be any content in the last row. Did you set the correct Grid.Row
value correctly?
You may be overriding the layout behavior of the last row's content. Are you setting the content's VerticalAlignment
to anything other than Stretch
?
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