2

I'm programming in C#(WPF). I use Grid with 4 row as below:

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition>
        <RowDefinition>
        <RowDefinition>
        <RowDefinition>
    </Grid.RowDefinitions>

    <!-- Height of this row is related to its content -->
    <Grid Row="0">
    </Grid>

    <!-- Height of this row is related to its content -->
    <Grid Row="1">
    </Grid>

    <!-- Remaining of Height should be used here... -->
    <Grid Row="2">
    </Grid>

    <!-- Height of this row is related to its content and this row should be stick to bottom of page  -->
    <Grid Row="3">
    </Grid>

</Grid> 

According to comments in my XAML code:

  • in Row=0, Height is related to its content
  • in Row=1, Height is related to its content
  • in Row=3, Height is related to its content and this row should be stick to bottom of page
  • in Row=2, Remaining Height should be used here

How can I adjust my row definitions according to four named conditions?

for more imagination see this picture: enter image description here

Babak.Abad
  • 2,839
  • 10
  • 40
  • 74

1 Answers1

2

I'm not on Windows right now so I cannot test it, but I'd try something like this.

In your RowDefinition:

<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>

Height="Auto", means that the row will take only as much height need by its content.

Height="*", means that the row will take all the remaining height available.

Mathieu
  • 1,638
  • 2
  • 27
  • 50
  • 1
    This works. The 3rd row having the `*` height will make sure that the 4th row is always pushed to the bottom of the page. – Stewbob Feb 25 '16 at 19:14