"....The CellControlAttached event not only fires when a cell is brought into view, but it also fires when a cell binding is refreshed due to an underlying change in the datasource...."
Within the event how do we know, if the event was fired due a change in the underlying datasource or it was just brought into view (by switching between screens etc..)?
Pls. advice.
The CellControlAttached is only going to fire for cells that are in view that have a data update. So if your cell was scrolled out of view at the time, even if the value changed you wouldn't be notified through the event.
You could use the ConditionalFormatting feature in the grid to do this for you. Otherwise if you are committed to doing the styling yourself you would need to do some tracking.
As a suggestion you could use the .Tag value of the cell to record the value of the cell in question and if it refires check the value to see its changed since the last time you checked the value.
so something like this in your CellControlledAttaced
for this psudocode I am assuming you are only tracking a single column (called DollarValue) off an object typed MyObject
if e.Cell.Column.Key == DollarValue
MyObject myObj = e.Cell.Row.Data as MyObject;
if e.Cell.Tag == null // this cell has never been rendered
e.Cell.Tag = myObj.DollarValue;
else // we have rendered this cell before
{
double exitingValue = (double) e.Cell.Tag; // get the existing vlaue out of tag, DollarValue is a double
if (existingValue != myObj.DollarValue)
// do styling
}
We want to change the background color of the cell only during binding datasource refresh. (to highlight realtime updates)..
currently i'm setting the style in the cellcontrolattachedevent.. the problem is the color changes not only during datasource changes... but also when the user switches to another screen and then comesback to the original screen...
There isn't a way to tell, but why do you need to know this? Could you tell me your use case?