Disapear setted background color of GridViewCell on Scroll RadGridView

2 posts, 0 answers
  1. Reza
    Reza avatar
    1 posts
    Member since:
    Sep 2015

    Posted 14 Sep 2015 Link to this post

    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;



  2. Ivan Ivanov
    Ivan Ivanov avatar
    1201 posts

    Posted 14 Sep 2015 Link to this post


    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.

    Ivan Ivanov
    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
Back to Top