This project shows how to create a custom base collection class that provides sorting functionality. It uses sort descriptions for definitions and LINQ for sorting operations.
This project provides a custom base ObservableCollection class that has been extending to support sorting functionality built upon an Extension method that can dynamically add LINQ order by's to a query.
It makes use of a SortDescription class to provide a property name to sort against, and a sort direction.
The property name can be used in 3 different ways.
A property directly on the initial item pointing to a value type
A property down an object graph using dot notation (IE. "Address.Country") Note - Currently does not support dot notation down to items in child collections
A property directly on the initial item, or a property using dot notation pointing to an object type (Must use IComparable on the object for this to work)
The processing uses reflection and LINQ to build a master ordering query, performs execution and re-orders itself based on the sorting.
Supports ICollectionChanged for binding