Hi
I am referring following article on your website to set the Foreground property of a cell using a Converter and CellValuePresenterStyle
http://es.infragistics.com/community/blogs/alex_fidanov/archive/2010/01/12/howto-using-wpf-converters-to-style-the-xamdatagrid.aspx
My requirement is fairly simple, I need all Numeric cells where the value is less than zero (negative value) to be painted in RED. That means Foreground should be RED. I have followed all the steps excatly as per the article and I am able to acheive what I want. Now the grid shows all negative values in RED. but when I scroll horizontally or vertically within the grid, many of the Positive Values are also being shown as RED.
I have created following style in my XAML;
<Style x:Key="styleNegativeValues" TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Foreground" Value="{Binding Value, Converter={StaticResource doubleToColorConverter}, RelativeSource={RelativeSource Self}}"/>
</Style>
I am using this style to set the CellValuePresenterStyle in my code as follows;
foreach (Field field in xamFlatGrid.FieldLayouts[nIndex].Fields)
{
if (field.DataType == typeof(double) || field.DataType == typeof(Int64))
field.Settings.CellValuePresenterStyle = (Style)this.FormObject.Resources["styleNegativeValues"];
}
My Converter code (Convert method) is as follows;
if(value == null)
return Binding.DoNothing;
else if (value is double)
double temp = (double)value;
if(temp < 0)
return Brushes.Red;
else if (value is Int64)
Int64 temp = (Int64)value;
Am I missing something here. Please help.
Regards,
Shish
Thanks NASH,
This fixed the issue. Thanks again
Hi!
This issue could be resolved by adding two else statements in the converter code like this:
if (value == null)
if
(temp < 0)