I have an application that reads database tables and puts it into a treeview. The current ItemTemplate for the treeview looks like this:
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding SubOrganLocations}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="35" />
<ColumnDefinition Width="35" />
<ColumnDefinition Width="35" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Column="0" Text="{Binding OrganDisplayName}" />
<TextBox Grid.Column="1" IsEnabled="True" />
<TextBox Grid.Column="2" IsEnabled="True" />
<TextBox Grid.Column="3" IsEnabled="True" />
</Grid>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
However, in the future there could be more columns that need to be added (determined by the number of distinct values in a table), so I'm trying to create it dynamically. How would I go about doing that?