Search code examples
c#wpfwpf-grid

WPF How to put button into row which is inside column


How can I put button into row which is inside column?

   <Grid.ColumnDefinitions>
        <ColumnDefinition Width="200" />
        <ColumnDefinition MinWidth="300" Width="*" />
    </Grid.ColumnDefinitions>
    <Grid Grid.Column="1">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition MaxHeight="50" MinHeight="50"/>
        </Grid.RowDefinitions>
    </Grid>

Grid.Row="2" is out of index. Grid.Colum="1" puts the button into correct column. What might be the correct way to use those rows?


Solution

  • Your initial row index guess was correct. You just need to put your button in the proper place in your XAML.

    <Grid>
      <Grid.ColumnDefinitions>
        <ColumnDefinition Width="200" />
        <ColumnDefinition MinWidth="300" Width="*" />
      </Grid.ColumnDefinitions>
      <Grid Grid.Column="1">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition MaxHeight="50" MinHeight="50"/>
        </Grid.RowDefinitions>
        <Button Grid.Row="2"/>
      </Grid>
    </Grid>