2011-10-08 102 views
0

我想自己處理所有排序,所以在Datagrid的_Sorting事件中,我設置了e.Handled = True。但是WPF仍然觸發集合刷新,並且似乎忽略了Handled標誌。WPF Datagrid:取消排序事件(WPF Bug?)

當我看到堆棧跟蹤,我看到:

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屬性不應該阻止這些調用被觸發嗎?

回答

0

爲什麼不考慮使用DataGrid.CanUserSortColumns/DataGridColumn.CanUserSort屬性設置爲false?

您要做的事可能不會與Sorting事件相關聯。

+0

因爲如果我將CanUserSort設置爲false,則列變爲「不可點擊」。他們沒有得到焦點或顯示排序箭頭,他們變得靜止。我想爲我的集合實現自定義排序,而不是禁用排序UI。 – Muis