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

Vertical Scrolling CellStyle issue

1 Answer 70 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Richard Harrigan
Top achievements
Rank 1
Richard Harrigan asked on 14 Mar 2013, 10:31 PM
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();
    }
}

1 Answer, 1 is accepted

Sort by
0
Yordanka
Telerik team
answered on 15 Mar 2013, 03:03 PM
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.

Tags
GridView
Asked by
Richard Harrigan
Top achievements
Rank 1
Answers by
Yordanka
Telerik team
Share this question
or