You will need to create the "Name1", "Name2" and "Name3" columns explicitly yourself. The DataGrid will only create columns for the Key and Value properties of the KeyValuePair in the Dictionary when you set the Dictionary as the ItemsSource for it.
My blog post about how to display and edit many-to-many relational data in a DataGrid should give you a clue on how to create dynamic columns if that's what you need: http://ift.tt/1kvdIIU.
Remember that the number of columns in the DataGrid will always be the same for each row regardsless of whether there are different number of items in the List<myClass> for the different KeyValuePair<int, List<myClass>> in the Dictionary.
The easiest solution would be to create another class that has an int property for the index column and a string column for each column that you want to display in the DataGrid ("Name1", "Name2" and "Name3") and then set the ItemsSource to a collection (e.g. List<T>) of this class.
No comments:
Post a Comment