Try something like this:
<local:CountryToColorConverter x:Key="countryToColorConverter"/>
<Style TargetType="{x:Type xcdg:DataCell}">
<Setter Property="Foreground"
Value="{Binding Converter={StaticResource countryToColorConverter}}"/>
</Style>
public class CountryToColorConverter : IValueConverter
{
public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
if( value == null )
return Brushes.Black;
System.Data.DataRow row = value as System.Data.DataRow;
if( row != null )
{
if( ( string )row[ "ShipCountry" ] == "Canada" )
{
return Brushes.HotPink;
}
if( ( string )row[ "ShipCountry" ] == "Brazil" )
{
return Brushes.Green;
}
}
return Brushes.Black;
}
public object ConvertBack( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture )
{
return Binding.DoNothing;
}
}
Technical Writer - Xceed Software
Of all the things I've lost, I miss my mind the most. - Mark Twain