locked
Change background color of all cells for a column in a Datagrid RRS feed

  • Question

  • Hi,

    I need to programmically change the color of all cells for a colunm based upon the data in the column header. For example if the column header is "May" I need to color all column cells yellow. I looked at using:

     <data:DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <TextBlock Foreground="{Binding Change,Converter={StaticResource changeColor}}" />
                    </DataTemplate>
    </data:DataGridTemplateColumn.CellTemplate>

     But it appear that it's based opon the value of the cell, not the header. Is there a way I can access the header data or an outside arraylist value?

    Thank you for your support

    Steve Ellis 

     

     

    Wednesday, September 2, 2009 9:22 AM

Answers

  • In a DataGrid the rows will always bind to the elements of the ItemSource.

    You could try using ElementName or a StaticResource.

    A third way is to have a property on your itemssource that reproduces the color of the header.

     

    Wednesday, September 2, 2009 9:43 AM