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
3160
DataItem is null for cellvaluepresenter style
posted

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

MatrixGridProblem.zip
Parents
  • 35319
    Verified Answer
    posted

    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.

Reply Children