WPFToolkit DataGrid does not sort a SortableBindingList

Jan 14, 2009 at 9:35 AM
Hi,

I have implemented sorting into a BindingList, but the datagrid does not sort. Actually, it doesnt try to sort at all, except that it checks that the SupportSortingCore property is true. The ApplySortCore method is never called.

Both List<T> and ObservableCollection<T> works as expected, but I need this implementation to work with the IBindingList interface.

    public class SortableBindingList<T> : BindingList<T>
    {       
        protected override bool SupportsSortingCore
        {
            get { return true; }
        }

        protected override void ApplySortCore(PropertyDescriptor prop, ListSortDirection direction)
        {
        }
    }



Jan 24, 2009 at 8:45 AM
Hello Moander,

did you find a solution for sorting a BindingList for the datagrid in WPF?

I also tried to implement the SortableBindingList but encounter the same problem you describe.
What I'm trying to do is binding a WPF datagrid to a collection of objects filled by Linq to Sql.
I tried several approaches but end up with two possibilities:

1) I can sort the grid but not insert or delete records
2) I cannot sort the grid but I can insert or delete records.

These are some links I used during my research:
http://www.codeplex.com/BeTimvwFramework
http://www.timvw.be/presenting-the-sortablebindinglistt/
http://www.timvw.be/improvements-for-the-sortablebindinglist-and-typedlist/
http://msdn.microsoft.com/en-us/library/ms993236.aspx
http://mikestedman.blogspot.com/2008/11/objectdataprovider.html
http://blah.winsmarts.com/2007-2-WPF__DataBinding_with_any_object,_Including_LINQ-ADONET_Entity_FrameWork.aspx
http://dotnetslackers.com/articles/wpf/WPFDataBindingWithLINQ.aspx
http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2008/10/01/10798.aspx
http://www.wpfmentor.com/2008/12/observable-collections-independent-of.html


Anyone have any ideas?


Regards,

Jeroen
Jan 27, 2009 at 10:27 AM
Hi

I was not able to solve this problem. My solution in the end was to rewrite my whole application to use ObservableCollection instead of a IBindingList implementation.

Best regards,
Morten