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

[Solved] CellStyleSelector not being applied

2 Answers 122 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Zainab Vora
Top achievements
Rank 1
Zainab Vora asked on 20 Oct 2010, 08:56 PM
Hello,

I am currently facing a problem with CellStyleSelector,

I have RadGridView bound with a Collection of GridViewColumns, I am applying CellStyleSelector to each of these columns. I have virtualization on due to large dataset.

When the grid is displayed, the first intial view has all the style applied correctly, but then when I scroll, my StyleSelector is called, it returns the style too depending on my conditions, but when the grid is displayed the style is not applied.

And the StyleSelector is not called for all the cells displayed after scrolling to previously viewed part of the grid. Its called for a few cells and the style is not applied for these few cells (even though StyleSelector is called only for them.)

Here is my code for CellStyleSelector
public class MyStyleSelector : StyleSelector
    {
        private static readonly Brush DefaultBackgroundBrush = new SolidColorBrush(Colors.Brown);
 
        public override System.Windows.Style SelectStyle(object item, System.Windows.DependencyObject container)
        {
            var style = new Style(typeof(GridViewCell));
            var background = DefaultBackgroundBrush;
            style.Setters.Add(new Setter(GridViewCell.BackgroundProperty, background));
            return style;
        }
}

Here is how i declared my style in xaml, and assign it to the column,

<!--xaml file-->
<Controls:MyStyleSelector x:Key="styleSelector"/>
 
//c sharp code
gridViewDataColumn.CellStyleSelector = App.Current.Resources["styleSelector"] as StyleSelector;

I am also using customised Scroller (GridViewScrollViewer).

I am using GridView version 2010.2.714.1030

I am also attaching an image,
here the complete row was to be colored brown,

2 Answers, 1 is accepted

Sort by
0
Zainab Vora
Top achievements
Rank 1
answered on 20 Oct 2010, 09:06 PM
Here is the image
0
Maya
Telerik team
answered on 21 Oct 2010, 02:40 PM
Hi Zainab Vora,

The behavior you are experiencing is not the expected one and still I cannot reproducing it by using only the code-snippet you provided. So, I would need more details about your application. What is the custom scroll viewer that you are using ? Furthermore, I would recommend you to upgrade to Silverlight 4 and our corresponding RadControls. Thus you will benefit from all the new features and fixes we develop and include.

Kind regards,
Maya
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Zainab Vora
Top achievements
Rank 1
Answers by
Zainab Vora
Top achievements
Rank 1
Maya
Telerik team
Share this question
or