Search code examples
c#wpfwpfdatagrid

WPF DataGrid: setting style for an individual cell


I am trying to change the foreground color of a DataGrid cell.

I am trying to use a class extending IMultiValueConverter and I'd like to bind it the item used to generate a row and to the name of the column.

I read other Q&A and I saw they suggest to use a MultiBinding but I am not sure about how I could add the bindings


Solution

  • I managed to solve my issue.

    I needed to change the properties I wanted to highlight with a different color decorating them so that they now contain the information about whether their value needed special formatting.

    Then I created a binding for each DataGrid column as it is described in this other Q&A. I bound the decorated property and I used an IValueConverter to obtain the Brush color I wanted to use.