WPF Datagrid:取消排序事件(WPF Bug?)
我想自己处理所有排序,因此在 Datagrid 的 _Sorting 事件中,我设置 e.Handled = True。然而,WPF 仍然会触发集合刷新,并且似乎忽略了 Handled 标志。
当我查看堆栈跟踪时,我看到:
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
这是 WPF 中的错误吗?因为 Handled 属性不应该阻止这些调用被触发吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你为什么不考虑使用
DataGrid.CanUserSortColumns
/DataGridColumn.CanUserSort
属性设置为 false?您想要执行的操作可能与
Sorting
事件无关。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.