Aki24x
Aki24x

Reputation: 1068

Resizing another grid row size in WPF

I am wondering is there any way to solve this by changing XAML code?

Please look at this sample picture:

enter image description here

What I wants to do is when user dragging GridSeparater No.1, I want to resize thr 3rd row of grid.

This is because in this application, the first and third rows are variable size, but second one is fixed size.

Is that possible?

Upvotes: 2

Views: 976

Answers (2)

Gimno
Gimno

Reputation: 6606

This is possible with ResizeBehaviour="PreviousAndNext" (Link to MSDN). This enables you to specify which rows should be affected relative to the GridSplitter.

<Grid Width="300" Height="200" Background="Yellow"  ShowGridLines="True">
  <Grid.RowDefinitions>
    <RowDefinition Height="*" />
    <RowDefinition Height="20"/>
    <RowDefinition Height="*"/>
  </Grid.RowDefinitions>

                  <GridSplitter Grid.Row="1"
                      ResizeDirection="Rows"
                      ResizeBehavior="PreviousAndNext"
                      HorizontalAlignment="Stretch"
                      VerticalAlignment="Top"
                      Background="Black" 
                      ShowsPreview="True"
                      Height="5" 
                      />



</Grid>

Upvotes: 4

John Bowen
John Bowen

Reputation: 24453

You could try setting both MinHeight and MaxHeight to the same value on the center row which would force recalculation of the bottom section when resizing the top. Something like this:

  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="50" MaxHeight="50" MinHeight="50"/>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="Auto"/>
    </Grid.RowDefinitions>        
    ... other content
    <GridSplitter Height="3" Grid.Row="1" HorizontalAlignment="Stretch"/>
    <GridSplitter Height="3" Grid.Row="3" HorizontalAlignment="Stretch"/>
  </Grid>

Upvotes: 1

Related Questions