WPF DataGrid AutoColumn generation via ICustomTypeDescriptor.
- by panamack
In a test project I've managed to AutoGenerate WPF DataGrid columns in the following scenario, where the data is stored in a Dictionary and binding is performed via PropertyDescriptors:
public class People:List<Person>{
...
}
public class Person:Dictionary<string,string>,INotifyPropertyChanged,ICustomTypeDescriptor
{
}
The problem I'm having is in my real life project I'm using MVVM so it's *People*ViewModel which inherits ViewModelBase and hence can't inherit List<Person>. I've tried implementing IList<Person> instead with an internal List<Person> and explicitly setting the DataContext to an IList<Person> reference but that didn't work.
I've seen a similar post on binding a win forms DataGridView here, so I'm wondering if the same sort of logic applies in WPF and primarily, what exactly causes the ICustomTypeDescriptor implementation to be picked up when inheriting List<T> that is missing when you simply implement IList<T> instead.