Skip to content

WPF DataGrid has erratic SelectAll performance #5588

Answered by ThomasGoulet73
vsfeedback asked this question in Q&A
Discussion options

You must be logged in to vote

Hey,

This is related to the difference between class and struct. DataGrid needs compare the items in ItemsSource very frequently. In the case of SelectAll, it needs to compare every item to a growing list to make sure that it doesn't select the same item twice. It gets exponentially slower the more items there are in the DataGrid. For classes, the comparison is extremely fast because it does so by comparing the reference of the two classes. For structs, it's a bit different since they are value types and therefore have no "reference". To compare two structs, it uses the Equals method. If the Equals method is not implemented in the struct, it will automatically do the comparison by compari…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by vishalmsft
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
3 participants
Converted from issue

This discussion was converted from issue #5403 on October 28, 2021 11:42.