Hello members,
I have tables (DBTable) in SQL 2008 that contains two columns that look like this:
Col1 Col2
0 1
0 1
1 1
1 1
0 1
I created a Silverlight application (BI -RIA and domain services) that populates the datagrid as follows
MyCarsDomainContext context = new MyCarsDomainContext();
dataGrid1.ItemsSource = context.DBTables;
context.Load(context.GetDBTablesCompareQuery());
I would like to change the row background color (just
the text color will work fine too) based on the value of Col1. If 0 then row is red, if 1 then row is blue
Any help is greatly appreciated
Sanjay DholakiyaPosted Feb 27, 2014, 7:42 PM
In this situation, it's batter to create one class and bind a list of that class with grid.
For example.
public class DBTable
{
public int Col1{get; set;}
public int Col2{get; set;}
}
Now, bind Foreground propery of your label in grid template with Col1. And also write on converter that converts this int value in to your color.
That's it.
Hope this helps!
- Sanjay Dholakiya