Hello,
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)
{
CommandManager.InvalidateRequerySuggested();
}
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.
Regards,
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.