Why are WPF Grid.Rows zero-based, and not relative?
grid, wpf
Solution
Is there some reason that the Grid.Row values don't act this way?
This would require the Grid to determine every possible row (by iterating all of it's children) during it's layout, and then placing the items. This would slow down and complicate the layout pass.
By making the grid row's explicit, this is avoided, and it helps the overall performance of the layout pass when the Grid arranges it's children.
HTML Z-Index values work like this
FYI - the `Canvas` class, in WPF, also uses this approach for Z indexing.
Problem
If I have a grid with five rows in it, the Grid.Row values are always 0, 1, 2, 3, and 4. If, during design-time, I want to insert a row after the first row, I will set its Grid.Row value to 1, but then I need to update the Grid.Row values for the four rows below the inserted row. This is annoying and error-prone. Instead, if Grid.Row values were something like relative (I don't know the best word to describe this), I would set the Grid.Row values to 10, 20, 30, 40, and 50. In this case, if I wanted to insert a row after the first row, I would set its Grid.Row value to 15. I wouldn't need to change any other rows. The layout engine would know to put the rows in ascending order. Is there some reason that the Grid.Row values don't act this way? HTML Z-Index values work like this