Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
40
Changing the cell text color based on other data in the grid
posted

Hi

I am trying to build a stock ticker type of application (similar in some ways to the xamTrader demo application) which uses a xamDataGrid bound to a collection. A thread process updates objects in the collection when a new price comes along and records on one field whether the price has gone up, down or stayed the same.

What I would like to do is have the grid set the colour for the price column according to this other field when it changes.

Back in the WinForm days I used the RowCellStyle event and in the event code used GetRowCellValue to get the "direction" value from a named (and hidden) column, check if the cell was one I wanted to color and then and then set the cell color accordingly.

How would I go about doing this in the WPF xamDataGrid?

 Thanks

  • 138253
    Offline posted

    Hello littledragon,

    Thank you for your post. I have been looking through it and I suggest you see this blog:

    http://blogs.infragistics.com/blogs/alex_fidanov/archive/2010/01/12/howto-using-wpf-converters-to-style-the-xamdatagrid.aspx

    where it is described how to use Converters for conditional formatting. There is also a sample demonstrating it. Also if you want, you can bind to another cell’s value by setting the path of the binding to Record.Cells[2].Value e.g. to bind to the 3rd cell’s value of the Record. Please note, we are making efforts to ensure all posts are addressed by an Infragistics expert. We believe that the other community members could benefit from this thread as well.

    Feel free to write me if you need further assistance.