CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Sorting a SortedBindingList

rated by 0 users
This post has 0 Replies | 1 Follower

Not Ranked
Posts 1
dgoldin Posted: Wed, Sep 26 2007 6:30 AM
Hello,

I have a small question concerning sorting a SortedBindingList using the mechanisms the WPF CollectionView offers.
I try to sort it with the following "official" approach:

ICollectionView cv = CollectionViewSource.GetDefaultView(_poiList.ItemsSource);                      

SortedBindingList<PointOfInterest> sbl = (SortedBindingList<PointOfInterest>)_poiList.ItemsSource;
sbl.ApplySort(sortBy, direction);

cv.Refresh();  

Unluckily it has no effect at all.
Is there a different way of doing this using WPF mechanisms without calling ApplySort() on the list directly (this is actually my current workaround, but not very elegant since I do grouping using GroupDescriptions)?

The CollectionView Refresh() method calls on RefreshOverride of the BindingListCollectionView method, which in turn calls on ConvertSortDescriptionCollection, also contained in the BindingListCollectionView class, which does the following:

ITypedList internalList = this.InternalList as ITypedList;
if (internalList != null) {
// more conditions and somewhen a call an ApplySort()
}


Any idea why it checks whether the list implements ITypedList? As far as I understand its not relevant for sorting but for DataBinding itself. The MSDN documentation for ITypedList states that one either needs to implement a ITypedList or to use a strongly typed Item in the List which is given by the use of generics if I understand correctly.

Is this a known issue? Why does SortedBindingList does not implement ITypedList?

Thanks a lot in advance,
    Dimitri
Page 1 of 1 (1 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems