CellStyleSelector not being applied while scrolling

3 posts, 0 answers
  1. Amara
    Amara avatar
    4 posts
    Member since:
    Apr 2010

    Posted 29 Oct 2010 Link to this post

    Hi Telerik Team,

    I am currently using CellStyleSelector feature of a GridViewDataColumn to apply selective styles.

    But styles are not being applied properly to few cells in middle when the grid is scrolled.

    We bound the columns to the grid using _grid.Columns.AddRange(columns);
    Rows are also added to the grid using _grid.ItemSource(rows).

    I am creating MyStyleSelector.cs in following way
    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;
           }
       }

    and applying it to the gridcolumn
    gridViewDataColumn.CellStyleSelector = App.Current.Resources["styleSelector"] as StyleSelector;

    I am currently using RadControls version 2010.2.714.1030. and Silverlight 3. Moving to silverlight 4 is not an option currently.

    Any help would be appreciated.

    Thank you.
  2. Amara
    Amara avatar
    4 posts
    Member since:
    Apr 2010

    Posted 02 Nov 2010 Link to this post

    Hi Telerik team,

    I have been able to reproduce the problem in a simple project. I am creating a support ticket for this issue and attaching the Project.

    Thank you.
  3. DevCraft banner
  4. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 03 Nov 2010 Link to this post

    Hello Julia POKHVALIEVA,

    Looking at the code-snippet and the sample project you provided, I may suggest to you a couple of options that will achieve the same result, but without causing the undesired effect you are getting. Firstly, you may define an implicit style for the row and set its Background property (in case of Silverlight 3 you have to define the Key modifier of the style and then set it as the RowStyle):

    <UserControl.Resources>
       <Style TargetType="telerik:GridViewRow">
        <Setter Property="Background" Value="Blue" />
       </Style>
    </UserControl.Resources>
     
    Silverlight 3:
    <UserControl.Resources>
      <Style x:Key="RowStyle" TargetType="telerik:GridViewRow">
        <Setter Property="Background" Value="Blue" />
      </Style>
    </UserControl.Resources>
     
    <grid:RadGridView x:Name="_grid" RowStyle="{StaticResource RowStyle}" />

    Another approach may be to set the Background property of the row during the RowLoaded event. Furthermore, if you do not support a lot of data, you may turn off the horizontal virtualization by using the EnableColumnVirtualization property of the grid.
     

    Best wishes,
    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
Back to Top