I am building out a XamDataGrid in code. I add columns to the grid based on values in my data. I need to create bindings with converters in code so I can set the background and foregraound colors of cells.
The attached example runs and demonstrates the structure of the grid I am trying to build. However I cannot set the background / foreground color of the grid cells.
Please look in the BrokerColumnConverter class and remove the commented lines to cause the app to crash.
I am sorry for providing such a complex example however it fairly represents my project.
Note I am adding UnboundFields to the grid........ is there a way to use Field instead as I understand they are faster.
Thank you,
Sam
Hello,
Thank you for your post. I have been looking into your sample application and I would like to know, how exactly you would like to customize your XamDataGrid by applying the CellValuePresenter style.
Please attach a descriptive screenshot.
Regarding your converter, the first thing you could do is to insure that the dataitem of the current record is not null like :
if ((value[0] as DataRecord).Cells[0].Record.DataItem != null)
{
}
Looking forward to hearing from you.
Hi Yanko,
>> I would like to know, how exactly you would like to customize your XamDataGrid by applying the CellValuePresenter style.Per my original post - "I need to create bindings with converters in code so I can set the background and foregraound colors of cells."
>> the first thing you could do is to insure that the dataitem of the current record is not null like :I do not understand why the converter is called to convert nothing.... but I added the code you suggested, thanks.
My example had some bugs in it which I fixed. Will you please explain to me how I can use a Field versus unbound field to accomplish what this examaple shows?
Thank you,Sam