WPF DataGrid AutoColumn generation via ICustomTypeDescriptor.

Posted by panamack on Stack Overflow See other posts from Stack Overflow or by panamack
Published on 2010-04-29T14:21:06Z Indexed on 2010/04/29 20:37 UTC
Read the original article Hit count: 1204

Filed under:
|
|

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.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf