Designing Grid wpf

63 views Asked by At

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

1

There are 1 answers

1
Mathieu On BEST ANSWER

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.