Vertical Scrolling CellStyle issue

2 posts, 0 answers
  1. Richard Harrigan
    Richard Harrigan avatar
    235 posts
    Member since:
    Nov 2009

    Posted 14 Mar 2013 Link to this post

    Hi,

    Code below!

    I am using a converter to change the fontweight or foreground color.  The problem only occurs when the number of rows exceed available screen space.  Assume that the visible portion of the column has one visible cell with a fontweight of Bold.  When you scroll down to see the remaining rows there may be one row where that cell is also bold.  Also of interest is that the converter was not executed for someof the scrolled items.  When I increase the screen height and try it again there is no problem.

    Thanks
    Rich



    <telerik:GridViewDataColumn
            IsFilterable="False" 
            Width="*"
            Name="ColumnName"
            Header="Column Name"
            DataMemberBinding="{Binding ColumnName}">
        <telerik:GridViewDataColumn.CellStyle>
        <Style TargetType="telerik:GridViewCell">
    <Setter Property="FontWeight" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Converter={StaticResource FontConverter}}"/>
                    <Setter Property="Foreground" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Converter={StaticResource ForegroundConverter}}"/>
    </Style>
        </telerik:GridViewDataColumn.CellStyle>
    </telerik:GridViewDataColumn>


    public class FontConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            FontWeight fontWeight = new FontWeight();
            AvailableColumnItem availableColumnItem = ((GridViewRowItem)((GridViewCell)value).ParentRow).DataContext as AvailableColumnItem;
            if (availableColumnItem.IsPrimaryKey)
                fontWeight = FontWeights.Bold; 
            else
                fontWeight = FontWeights.Normal;
            return fontWeight;
        }

            public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
            {
                throw new NotImplementedException();
            }
        }
    }


    public class ForegroundConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Brush foreground; 
            AvailableColumnItem availableColumnItem = ((GridViewRowItem)((GridViewCell)value).ParentRow).DataContext as AvailableColumnItem;
            Debug.WriteLine(availableColumnItem.ColumnName);
            if (availableColumnItem.IsPrimaryKey)
                foreground = new SolidColorBrush(Colors.DarkSlateGray);
            else
                foreground = new SolidColorBrush(Colors.Black);
            return foreground;
            }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

  2. Yordanka
    Admin
    Yordanka avatar
    634 posts

    Posted 15 Mar 2013 Link to this post

    Hi Richard,

    I've tried to reproduce the problem you report but to no avail. Could you try isolating it in a sample project and send it to us? We will check what is going on and will assist you further. 
    In order to attach a project you need to open a support ticket.
     
    All the best,
    Yordanka
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top