I have a class like this to be bind to a datagrid as itemsource:
public class Item
{
public int Id { get; set; }
public string Status { get; set; }
public Dictionary<string, string> DynamicProperties { get; set; }
}
I want to bind List<Item> to a silverlight datagird and display columns as this
id | Status | DynamicProperties[0] | DynamicProperties[1] | … …
How can I implement this?
With Silverlight 4 and above bindings with string indexers are supported. You simple bind with a path as follows:
For earlier version s of Silverlight, the solution is much more complex, as described on my blog.
If you want to create columns directly, just do this via code-behind. The blog post referenced above shows how to create a DataGrid dynamically.