WPF - Grid - updating Row and Column number attached properties on child controls each time a new Ro

Posted by ig105 on Stack Overflow See other posts from Stack Overflow or by ig105
Published on 2010-05-06T15:28:14Z Indexed on 2010/05/06 15:38 UTC
Read the original article Hit count: 457

Filed under:
|

I have a WPF Grid with a XAML similar to this:

  <Grid width=200 Height=200 >

        <Grid.ColumnDefinitions >                             
            <ColumnDefinition Width="1*" />
            <ColumnDefinition Width="2*" />
         </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"  />
            <RowDefinition Height="Auto"  />
            <RowDefinition Height="Auto" MinHeight="24" />
        </Grid.RowDefinitions>

      <TextBlock Text="Name" Grid.Row="0" Grid.Column="0"/>
      <TextBox Grid.Row="0" Grid.Column="1" />

      <TextBlock Text="Age" Grid.Row="1" Grid.Column="0"/>
      <TextBox Grid.Row="1" Grid.Column="1" />

  </Grid>

I need to add a new row in between existing 2 rows of data, but my worry is that when I add a new row, I will need to manually update Grid.Row attached property in each of the controls that appear in rows below the newly added row.

Is there a smarter way of doing this? may be to set Row/Column numbers relative to adjacent Rows/Columns ?

Cheers.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about wpf-controls