WPF - Grid - updating Row and Column number attached properties on child controls each time a new Ro
- by ig105
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.