0
votes

This is my situation: I have a TabControl and I have replaced its template with my own so that headers of TabItems are displayed inside a Grid thus spreading equally through available space. I put a setter inside a TabItem style whose value is bound to the ancestral Grid (the one mentioned before). I'm using a converter to assign Grid.Row to Grid.Children.IndexOf(TabItem) and in the process adding a RowDefinition to this Grid.

This works fine while adding TabItems (dynamically) but when I remove a TabItem, it doesn't refresh the values. So I figure I need to place a trigger so that every time Grid.Children is changed values get recalculated. I am unsure how to accomplish this.

1

1 Answers

0
votes

If all you want is equally sized cells, why not use UniformGrid instead of a Grid?

Set Rows = "1" on UniformGrid and every time you add/remove a child, it will allocate same size for all of them.