Firstly let me clarify (if the title wasn't clear enough): I'm discussing System.Windows.Controls.DataGrid
from the .NET 4.0 Framework, not the toolkit edition.
I'm currently building up a small re-usable set of classes/view models/etc in my project to build a rather powerfull DataGrid for my application.
Now, by default given an IEnumarable<>
ItemsSource the DataGrid control supports header-clicking column sorting.
However, my implementation now uses a CollectionViewSource
and ICollectionView
to expose data members to the DataGrid. When hooked up in this fashion it seems to rely on the SortDescriptions to sort.
While I like having control from code (could be hooked into all sorts of things) I also require the ability for my users to click the header bars to sort thier results. I'm looking for a way to hook the header-bar clicks to signal my code to adjust the CollectionViewSource
appropriately.
- Am I going to have to re-style the header buttons to do fire the events?
- Is there a way to hook the sort events from the DataGrid control's existing headers?
- What is the best way to go about this?
- Am I using
ICollectionView
incorrectly?