I have a DataGrid in my Silverlight application that I would like to highlight an entire column when that column is sorted.
It’s similar in concept to this previous question: Silverlight DataGrid: Highlight an entire column.
Any ideas? I’ve thought maybe attaching a behavior to the LayoutUpdated event and checking a cell to see if it’s in a sorted column?
There are several issues that you have to get around to do what you want to do. The biggest issue is that finding out when a column is sorted is a lot harder then it should be. The only way I have ever found to identify that a column was sorted to make
DataGrid.ItemsSourcea PagedCollectionView and listen to theCollectionChangedevent on itsSortDescriptionsproperty. If you use aPagedCollectionViewfor your ItemsSource and all columns that can be sorted on areDataGridBoundColumn(really any of the premades other than TemplateColumn) then this behavior should be fairly close to what you want to do.