In our WPF project, we have an issue with the Telerik data grid that,
> We have implemented a cell style for setting the background colour based on condition by using the MultiValue Converter,
Style code:
<Style x:Key="AFLinkCellFGStyle" TargetType="telerik:GridViewCell" BasedOn="{StaticResource {x:Type telerik:GridViewCell}}">
<Style.Resources>
<local:AFCellLinkFGConverter x:Key="AFCellLinkFGConverter"/>
</Style.Resources>
<Setter Property="Background">
<Setter.Value>
<MultiBinding Converter="{StaticResource AFCellLinkFGConverter}">
<Binding RelativeSource="{RelativeSource Self}"/>
<Binding />
</MultiBinding>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontWeight" Value="ExtraBold"/>
</Trigger>
</Style.Triggers>
</Style>
<Style.Resources>
<local:AFCellLinkFGConverter x:Key="AFCellLinkFGConverter"/>
</Style.Resources>
<Setter Property="Background">
<Setter.Value>
<MultiBinding Converter="{StaticResource AFCellLinkFGConverter}">
<Binding RelativeSource="{RelativeSource Self}"/>
<Binding />
</MultiBinding>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Foreground" Value="Black"/>
<Setter Property="FontWeight" Value="ExtraBold"/>
</Trigger>
</Style.Triggers>
</Style>
Converter code:
public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
{
if (values[1] is ArcFlashEvalRecord)
{
Efx.Assert(values[1] is ArcFlashEvalRecord && (values[1] as ArcFlashEvalRecord).pData != null, "FIX THIS - expecting ArcFlashEvalRecord and ArcBusData");
GridViewCell cell = values[0] as GridViewCell;
ArcFlashEvalRecord record = values[1] as ArcFlashEvalRecord;
GridViewColumn column = cell.Column;
if (column != null)
{
AF_FieldType field_type = (AF_FieldType)column.GetValue(AttachedProp.TagProperty);
return AFCellInfo.GetCellInfo(field_type, record).BgBrush;
}
}
return null;
}
{
if (values[1] is ArcFlashEvalRecord)
{
Efx.Assert(values[1] is ArcFlashEvalRecord && (values[1] as ArcFlashEvalRecord).pData != null, "FIX THIS - expecting ArcFlashEvalRecord and ArcBusData");
GridViewCell cell = values[0] as GridViewCell;
ArcFlashEvalRecord record = values[1] as ArcFlashEvalRecord;
GridViewColumn column = cell.Column;
if (column != null)
{
AF_FieldType field_type = (AF_FieldType)column.GetValue(AttachedProp.TagProperty);
return AFCellInfo.GetCellInfo(field_type, record).BgBrush;
}
}
return null;
}
Issue: The issue is the background colour is not set properly for each cell.
Description: Initially the data is loaded and the Telerik data gets rendered in the display, we have more than 10 columns, and some of the last columns are hidden. Initially, the background colour worked properly for all cells. but when we horizontally scroll to the end of the data grid to see the hidden columns, at that time, the background of the cell is not set properly, it randomly sets the background colour for hidden column cells. it's changing every time we scroll.