Home > Back-end >  How to change the color of a ListView column (each cell of each row) seperately in WPF?
How to change the color of a ListView column (each cell of each row) seperately in WPF?

Time:02-27

I have a ListView that regularly update and show some analyzed data.

Each row represent a different source and the columns show it's analyzed values.

What I want is to only change the Background color or Font Color of a single cell if a certain criteria is met.

For example if the "Price" Column value become less than X, it will change into Red Color background or font.

But I don't want the whole row to be changing color, but only the "Price" Column of that certain row.

I know how to change the color of a whole row, there has been many example of that in here as well, for example using binding. But I want to know if there is anyway to just change the Background Color or Font Color of a single Cell.

Thanks.

CodePudding user response:

GridViewColumn has a CellTemplate property that you can point to a DataTemplate for the cells. In the DataTemplate you can use a Binding Converter to map the values to the desired styling.

  • Related