0

I am trying to get brush color from red to green by passing %.I have a datagrid each row has a percentage value. Is there any function like getColor(Red,Green,%) which return the color from red to green a/c to %.

1 Answers1

0

You need to looking for a converter, that is a class that implements IValueConverter interface. You need to work with WPF binding.

public class BackgroundConverter : IValueConverter
{
    public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
    {
        Brush someBrush;
        // Put here your logic
        return someBrush;
    }

    public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
    {
        return null;
    }
}
Igor Damiani
  • 1,897
  • 9
  • 12