Hi,
In my XamDataGrid, i have given RecordContainerGenerationMode as "Recycle". For some Cells, i manually change visual appearence like Background, Foreground, FontFamily. When i am scrolling down or up, i use to see CellValuePresenter's with the customized appearence which i applied earlier. So it is using the same CellValuePresenter with the customized style. Is this a correct behaviour ?
If so When reusing a CellValuePresenter, the CellValuePresenter's current style needs to be removed and it should be defaulted to column's style ? How to achieve this?
Thanks
Kumaran Vellaisamy
HI,
What you are describing is normal behaviour.
If you modify a CellValuePresenter property, you should do this via a binding. This will prevent the incorrect manual modifications from being applied to other cells when scrolling.
Sincerely, Matt
Developer Support Engineer
Hello Matt,
1. I have defined a default style for CellValuePresenter2. At runtime, Background property of a particular Cell will be set by modifing its CellValuePresenter's Background property3. While scrolling, in CellsInViewChanged event i found that some of the CellValuePresenter's have default style and some CellValuePresenter's have the style with modified Background as CellValuePresenters are resued in Recycle mode. So the modified style gets applied for some Cells 4. While scrolling back to the Cell for which actually i modified the Background, am getting default CellValuePresenter style in CellsInViewChanged event. It doesn't have the modified Background in its CellValuePresenter
Queries:1. After modifing the Background of a particular CellValuePresenter, while reusing it in CellsInViewChanged event am expecting the CellValuePresenter to have the default style but sometimes it has the style with modified Background2. When scrolling back to the cell whose background property was set, am expecting CellValuePresenter returned in CellsInViewChanged event to have its actual background property, which is not the case as am getting CellValuePresenter with default style
I replicated your two queries. This is normal behavior. What criteria are you using to modify your cells background color?
You should set up bindings to the Background color of the cells. You could possibly add collapsed unbound fields to help with setting up the bindings.
Sincerely,
Matt
Please let me know if you need further assistance regarding this issue.
Sincerely, Matt Developer Support Engineer
You mentioned in your previous post "You should set up bindings to the Background color of the cells." Can you show me a code sample on this ?