This is a migrated thread and some comments may be shown as answers.

Disapear setted background color of GridViewCell on Scroll RadGridView

1 Answer 22 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Reza
Top achievements
Rank 1
Reza asked on 14 Sep 2015, 08:44 AM

I set specific cell background in grid click. But on grid scroll it set
back to default. I perefer not to use EnableRowVirtualization as False.
This is My Code:

<telerik:RadGridView ItemsSource="{Binding PersonList}" Name="grid"
Height="200" PreviewMouseUp="grid_PreviewMouseUp" >

private void grid_PreviewMouseUp(object sender, MouseButtonEventArgs e)
{
    var cell = (sender as RadGridView).CurrentCell;
    cell.Background = Brushes.Aqua;
}

 

Thank​

1 Answer, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 14 Sep 2015, 10:16 AM
Hi,

Directly modifying visual properties of RadGridView's elements (rows, cells) is not recommend as it uses container recycling. Thus the modified cell can be reused to display another cellinfo, which would result in inconsistent behavior. In order to achieve this, I would recommend that you use CellStyleSelector. To force the Selector to get invoked on mouseup, you can add a model property that indicates whether the cell should be colored, and then setting the property and raising ProeprtyChanged for it should do the trick.

Regards,
Ivan Ivanov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
GridView
Asked by
Reza
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Share this question
or