Won't Fix
Last Updated: 03 May 2022 13:40 by ADMIN
Created on: 05 Feb 2020 13:39
Category: GridView
Type: Bug Report
GridView: DataContext of rows is sometimes null when UI virtualization is enabled in the Flat group render mode
DataContext of rows is sometimes null when UI virtualization is enabled in the Flat group render mode.

The issue appears also without UI virtualization and in the Nested mode. It happens on ItemsSource reset of RadGridView, in case the old ItemsSource value wasn't empty. The DataContext is set to null for a brief moment before the old visuals are removed from the view, which causes issues in some scenarios related to CellTemplate
1 comment
Vladimir Stoyanov
Posted on: 03 May 2022 13:40


We investigated this scenario and as it turns out the behavior is expected. The DataContext of the visual elements inside the RadGridView(GridViewRows) is cleared when the viewport is scrolled up/down and also when the ItemsSource of the control is reset.

In both scenarios this behavior is desired. When the viewport is scrolled the RadGridView reuses the containers that it has created in order to improve the performance, which necessitates clearing a container when it goes outside the viewport (including its DataContext). Additionally when the ItemsSource is reset the DataContext of the GridViewRows is also cleared and the containers are stored for reuse.

This has lead to the following two scenarios, which we have observed related to placing a Button with a CommandParameter bound to the DataContext inside the cell of a GridViewRow:

1. The button may be disabled when it initially comes into view while the RadGridView is scrolled. You can avoid this by calling CommandManager.InvalidateRequerySuggested method when the button is loaded:

private void Button_Loaded(object sender, RoutedEventArgs e)

2. The button may receive null in the Execute method of its command (this can happen shortly after the ItemsSource of the RadGridView is cleared/replaced). To protect against this scenario you can include a null check for the parameter inside the Execute method of the button. 

I will proceed with changing the status of this item to "Won't Fix". Of course, feel free to contact us through our support system/forums, if you need additional help with this scenario or another similar one. 

Vladimir Stoyanov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.