Last Updated: 19 Feb 2018 15:13 by ADMIN
Created on: 22 Nov 2017 18:23
Category: GridView
Type: Bug Report
GridView: Binding ItemsSource and SelectedItem of GridView changes SelectedItem
I have a RadGridView and bind its ItemsSource and its SelectedItem to properties of the ViewModel (DataContext). I use a ViewModel for the grid items with overridden Equals and GetHashCode. When the ViewModel is created, the property bound to ItemsSource is filled and the property bound to SelectedItem is set to an item that is equal to one of the items in the collection (but not reference equal).

When the GridView is displayed, no item is selected.

Note: I already reported this issue before:
but now I have managed to modify the sample project so that the problem can be reproduced. The difference to the original sample project is that Equals and GetHashCode of the Club ViewModel are overridden and the selected item is not reference equal to the item in the collection.
Attached Files:
Posted on: 19 Feb 2018 15:13
The fix will be available in the R1 2018 SP2 Release.
Ivan Ivanov
Posted on: 29 Nov 2017 13:23
Thank you for reporting this issue. It is related to the fact that RadGridView’s UI virtualization cache works with object.ReferenceEquals, for creating and storing rows. The selection engine correctly assigns the item as a selected one, but none of the rows is actually selected. On the other hand, one of the main collections of RadGridView’s data engine uses object.Equals, which causes some other known issues that are observed when the business item type overrides Equals. We have some plans for introducing changes that will prevent the disparity between regular CLR types and ones that have Equals overridden. However, we will most certainly not include this update in the incoming R1 release. Please, subscribe to this item to track future changes. We will do our best to plan the implementation as soon as possible.