Hi
I need to change the background color of a cell based on its value while using AutoGenerateColumns="True
Without using code behind (attach property is acceptable solution)
The data context is System.Data.DataTable
Thanks in advance.
3 Answers, 1 is accepted
0
Dimitrina
Telerik team
answered on 02 Jan 2013, 08:58 AM
Hi,
You will have to define a StyleSelector and assign it for the corresponding column. As your columns are not defined in XAML, but they are auto generated, you will need access the auto generated column when the AutoGeneratingColumn event is fired.
Ok,but how do i set the binding in template to the correct column?
The only solution i can think of is to change the template with code for every column
Thanks in advance
0
Accepted
Dimitrina
Telerik team
answered on 02 Jan 2013, 12:05 PM
Hello,
Actually you do not need to define any template. In order to change the background colour for a cell you will need to define and apply a CellStyleSelector returning a Style targeting GridViewCell.
You can check the Cells WPF Demo and as well this help article about a general information on applying the CellStyleSelector.