开发者

WPF Datagrid: Cancel Sorting event (WPF Bug?)

开发者 https://www.devze.com 2023-04-11 11:38 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号