Hello,
I would like to bind cell background color to cell value (via converter of course). However when I declare style in GridViewResource like this:
which simply should return Brushes.Red.Color for value < 0 Green for value > 0 and left color White when value is equal to 0. In debug mode I discovered that value passed to value converter is eqal to whole object (I'm binding ItemSource to collection of custom business objects) instead of being equal to object property value which is binded to column.
When I try to do something like this:
it's even working, color is changed (value converter gets cell value), but I get an error:
"System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=H1; DataItem='DailyPosition' (HashCode=7712694); target element is 'SolidColorBrush' (HashCode=16353339); target property is 'Color' (type 'Color')
"
which cause low performance :(
Any ideas? How to get cell value in first style declaration?
Thanks in advance,
MC
I would like to bind cell background color to cell value (via converter of course). However when I declare style in GridViewResource like this:
<Style TargetType="{x:Type telerik:GridViewCell}"> |
<Setter Property="Background"> |
<Setter.Value> |
<SolidColorBrush Color="{Binding Converter={StaticResource decimalToColor}}" /> |
</Setter.Value> |
</Setter> |
</Style> |
When I try to do something like this:
<telerik:GridViewDataColumn Width="45" DataType="{x:Type sys:Decimal}" Header="H1" DataMemberBinding="{Binding Path=H1, Mode=TwoWay}" DataFormatString="{}{0:n0}" IsGroupable="False" IsSortable="False" IsFilterable="False"> |
<telerik:GridViewColumn.CellStyle> |
<Style TargetType="{x:Type telerik:GridViewCell}"> |
<Setter Property="Background"> |
<Setter.Value> |
<SolidColorBrush Color="{Binding Converter={StaticResource cellBGConverter}}" /> |
</Setter.Value> |
</Setter> |
</Style> |
</telerik:GridViewColumn.CellStyle> |
</telerik:GridViewDataColumn> |
it's even working, color is changed (value converter gets cell value), but I get an error:
"System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:Path=H1; DataItem='DailyPosition' (HashCode=7712694); target element is 'SolidColorBrush' (HashCode=16353339); target property is 'Color' (type 'Color')
"
which cause low performance :(
Any ideas? How to get cell value in first style declaration?
Thanks in advance,
MC