Question : wpf property or data trigger

I am trying to get a row in a datagrid to turn red if the value of a checkbox within the datagrid is true.  Any ideas?  Here is what I have so far.  I am currently turning the columns red if the mouse rolls over the row.

Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:

 

  

 

     
     
       
         
           
         
       
     
   

Answer : wpf property or data trigger

Check the code. Actually you can use datatrigger itself to do it but this is the better way as you can get broader picture of Valueconverters. here local is your local namespace.

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
//================USE Following in Resources====================


 
//=========Use following converter class in codebehind================
 [ValueConversion(typeof(bool), typeof(Color))]
public class StringToColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value)
                return Color.FromRgb(255,0,0);//red
            else
                return false;
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException("ConverBack should never be called");
        }
    }
Random Solutions  
 
programming4us programming4us