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();
}
}
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();
}
}