This question is locked. New answers and comments are not allowed.
It sounds great but it's not working like MS Datagrid, at least not in my version (using SP2).
I'm binding my itemssource property to a collection that implements IEnumerable<T>, ICollectionView. The items in the collection have DisplayAttribute on each property.
When the collection is empty (not null, just empty) no headers are displayed. If i add an item to the collection then the headers are displayed. I inspected your code using reflector and I've seen that the first you do when the ItemsSourceProperty changes is to check if it is an ICollectionView and if it's empty. If so, you register on the CollectionChanged event and don't care about the collection anymore until that event fires..which is wrong. You should always check if the collection implements IEnumerable<T> and get the <T> out of it to query for DisplayAttributes in the fields.
Another interesting thing is that even if the source collection really is empty but the ICollectionView.IsEmpty property returns false the RadGridView displays headers as expected.
I also noticed that the collection I bind to ItemsSource doesn't implement ICollectionView (just IEnumerable<T>) then it works as expected, so it's an ICollectionView handling issue.
On a side note..I also noticed that the RadGridView doesn't query the ICollectionView.CanSort property before querying the ICollectionView.SortDescriptionCollection property. When I was testing I had the SortDescriptioncollection property returning null and the CanSort return false. An exception was thrown because you tried to register via reflection in the CollectionChanged event without checking if the SortDescriptionCollection returned by the ICollectionView was null.
I'm attaching a sample solution so you can see what I'm talking about. I couldn't attach the solution here so I used megaupload for that..sorry.
http://www.megaupload.com/?d=XA0YCK2J
If you don't wanna open it at least see a screenshot of the sample running.
Best regards,
Manuel FelĂcio
I'm binding my itemssource property to a collection that implements IEnumerable<T>, ICollectionView. The items in the collection have DisplayAttribute on each property.
When the collection is empty (not null, just empty) no headers are displayed. If i add an item to the collection then the headers are displayed. I inspected your code using reflector and I've seen that the first you do when the ItemsSourceProperty changes is to check if it is an ICollectionView and if it's empty. If so, you register on the CollectionChanged event and don't care about the collection anymore until that event fires..which is wrong. You should always check if the collection implements IEnumerable<T> and get the <T> out of it to query for DisplayAttributes in the fields.
Another interesting thing is that even if the source collection really is empty but the ICollectionView.IsEmpty property returns false the RadGridView displays headers as expected.
I also noticed that the collection I bind to ItemsSource doesn't implement ICollectionView (just IEnumerable<T>) then it works as expected, so it's an ICollectionView handling issue.
On a side note..I also noticed that the RadGridView doesn't query the ICollectionView.CanSort property before querying the ICollectionView.SortDescriptionCollection property. When I was testing I had the SortDescriptioncollection property returning null and the CanSort return false. An exception was thrown because you tried to register via reflection in the CollectionChanged event without checking if the SortDescriptionCollection returned by the ICollectionView was null.
I'm attaching a sample solution so you can see what I'm talking about. I couldn't attach the solution here so I used megaupload for that..sorry.
http://www.megaupload.com/?d=XA0YCK2J
If you don't wanna open it at least see a screenshot of the sample running.
Best regards,
Manuel FelĂcio