I have a grid with an unbound field containing an image in control template for a CellValuePresenter. I want to show/hide this image or cell contents in code-behind. I am trying InitializeRecord event with this code:
Dim dr As DataRecord = CType
(e.Record, DataRecord)
Dim c As Cell = dr.Cells(5)
Dim cp As CellValuePresenter = CellValuePresenter.FromCell(c)
cp.IsEnabled = False (based on some condition of course)
But the cp is Nothing!
Can any help please?
Tahir
Hello Tahir,
InitializeRecord event s too early for the presenters to be generated. You will be able to access them as early as the Loaded event of the XamDataGrid. Because of the default virtualization settings, only the currently visible presenters will be generated, so you can use the GetRecordsInView() method to access only those.