I have a ‘matrix’ object like follows:
public class Matrix
{
public Dictionary<string, string> PropertyBags { ... }
// Sample Property Bag: [{"Column A", "A"}, {"Column B", "B"}]
public List<PropertyBags Row { ... }
}
I wonder what’s a practical solution for displaying my objects in WPF DataGrid?
Thanks.
Yep, you can do it in code behind of a Grid View. The idea is to bind a custom data set to a
grid.DataSourceproperty and then add columns dynamically, see examples by links below.Also the second link provides an good example using Dependency Property which bound to a
ItemsSourceof a grid in XAML, also DP hasOnPropertyChangedCallbackprovided so each time you update a data set by new value:Links to the examples: