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

CellStyleSelector not working with Virtualization Enabled

0 Answers 104 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mat
Top achievements
Rank 1
Mat asked on 06 Jun 2011, 09:35 AM
I have a generic CellStyleSelector that is applying styles based on the value the cell is bound to. Column and Row Virtualization is enabled on the grid. My style selector is reading the value of cell. When SelectStyle is called the value of the cell does not match the value of the underlying property on the object to which the column is bound. This is causing the wrong styles to be displayed after the user scrolls the grid.

Code below

public class GridViewCellStyleSelector : StyleSelector
{
    public override Style SelectStyle(object item, DependencyObject container)
    {
        if (container is Telerik.Windows.Controls.GridView.GridViewCell)
        {
            return SelectMyStyleForValue(((GridViewCell)container).Value);
        }
        else
        {
            return null;
        }
    }
}

The value of the ((GridViewCell)container).Value does not match the property on the item. This need this to be a generic method, hence this method does not know what property to evaluate on the item parameter. Is there a way to read the property on the item which the cell is bound to? Or should the value of the cell be updated before SelectStyle is called? I understand that virtualization is replacing the values of the cells and I do not want to disable this feature as my grid has a lot of data. 

I am using the latest internal build binaries 2011.1.530.40

Thanks


No answers yet. Maybe you can help?

Tags
GridView
Asked by
Mat
Top achievements
Rank 1
Share this question
or