Have a List bound as the itemssource for a grid. MyObject has properties that are in turn bound as the individual column bindings:
<data:DataGrid.RowDetailsTemplate>
<DataTemplate>
<data:DataGrid x:Name="MyGrid" ItemsSource="{ListOfMyObject}">
</data:DataGrid>
</DataTemplate>
</data:DataGrid.RowDetailsTemplate>
<data:DataGrid.Columns>
<data:DataGridTextColumn Header="FOO" Binding="{Binding Foo}" IsReadOnly="True" />
<data:DataGridTextColumn Header="BAR" Binding="{Binding Bar}" IsReadOnly="True" />
</data:DataGrid.Columns>
</data:DataGrid>
The class has properties Foo and Bar that get assigned from another property’s data. This property is a large set of data that is accessible by an indexer (essentially acts as a collection):
public class MyClass
{
public string Foo;
public string Bar;
public MainData Lots;
}
I need to be able to dynamically add columns to the grid from MainData, like MainData[217]. I’ve played around with this idea but can’t seem to tweak it correctly. Any pointers?
Wasn’t thinking clearly enough apparently.
Following the premise linked in the orignal post, I’ve added a separate List of IDs. Rather than attempting to spin through the source data and add columns, I spin through this list. These IDs in turn look up other values, e.g. header text, from a data dictionary and pass the ID (which serves as my indexer noted above) to the converter.