I want to handle all sorting myself, so in the _Sorting event of the Datagrid, I set e.Handled = True. However WPF still fires a collection refresh, and seems to ignore the Handled flag.
When I look at the stack trace, i see this:
PresentationFramework.dll!MS.Internal.Data.CollectionViewProxy.Refresh() + 0x2a bytes
PresentationFramework.dll!System.Windows.Controls.ItemCollection.RefreshOverride() + 0x53 bytes
PresentationFramework.dll!System.Windows.Data.CollectionView.Refresh() + 0x44 bytes
PresentationFramework.dll!System.Windows.Controls.DataGrid.PerformSort(System.Windows.Controls.DataGridColumn sortColumn) + 0xbe bytes
PresentationFramework.dll!System.Windows.Controls.Primitives.DataGridColumnHeader.OnClick() + 0x5d bytes
Is this a bug in WPF? Because shouldn't the Handled property prevent these calls 开发者_高级运维from being fired?
Why don't you consider to use DataGrid.CanUserSortColumns
/DataGridColumn.CanUserSort
property set to false?
What you want to do may not be linked with Sorting
event.
精彩评论