GetEnumerator of ObservableCollection and Bind to DataGrid

Mar 18, 2009 at 3:43 AM
I inherit from ObservableCollection and IEnumerable and implement the GetEnumerator function.

But I found it's still the original ObservableCollection result bind to ItemsSource of DataGrid, I really want to is my implemnted GetEnumerator as data bind to DataGrid.

Anyone knows the reason and solution
Mar 18, 2009 at 8:21 PM
I believe since you used ObservableCollection, the CollectionView is not accessing the items through the enumerator. Consider implementing a CollectionView subclass in order to return the items in the order that you desire. I believe you'll want to override GetItemAt. You might be able to derive from ListCollectionView.

Mar 19, 2009 at 2:42 AM
Thanks, I'll try it later :-)