Reputation: 2499
The problem:
I have a list of objects which have Date, Name, and Value Properties. Name and Date properties could be different or the same.
orange 2012-01-01 1
orange 2013-01-01 0
I'd like create a GridView with Headers (which are distinct dates) and rows
Name 2012-01-01 2013-01-01
orange 1 0
As you see objects do not have properties like '2012-01-01', so simple binding will not help.
Question
How can I create a binding using column's name?
This I'd like to do with XAML or converters, without using UserControl's events
Upvotes: 0
Views: 447
Reputation: 102743
Essentially what you need to do (as you've noticed) is create a list of objects with dynamic properties (that is, properties populated at runtime). The transformation itself is a pivot on Date, with a sum (?) across value, which you can perform using a GroupBy Linq query in your converter.
Now for the tricky part. Take a look at this answer:
You need to implement ICustomTypeDescriptor to implement dynamic properties. Good luck.
Upvotes: 1
Reputation: 22435
take your list of objects - create a new list of objects with your conditions. then simply put the new list as itemssource to a datagrid/itemscontrol.
Upvotes: 0