"....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.
There isn't a way to tell, but why do you need to know this? Could you tell me your use case?
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...
In this case I would say you should probably be handling this on the data level in your data object itself by recording meta data about your data. the XamGrid isn't going to know what happens off screen, by design.
I was trying to figure out a mechanism that would work for you, but in almost every case there would be an issue.
You could scroll thorugh all your rows and cells after binding and "pre-Tag" all your values. This assumes that rows won't be added to the datasource. so that is one limitation. The second would be that if off screen a value goes from 10 to 100 to 11, how would you expect the coloration to work? With this mechansim you would only possibly see the last transition with respect to the init value, so you would see a +1 rahter then the -89.
If it's possible I would say record metadata on your data object regarding your data transitions
something like
double MyData
{
get; // put code here
set
if (value != this._myData)
if _myData < value
_myDataLastTransition = MyNewTransitionEnum.ValueIncreased;
else
_myDataLastTransition = MyNewTransiitionEnum.ValueDecreased
}
MyNewTransitionEnum MyDataLastTransion {get {return this._myDataLastTransition}
You would probaby want to add INotifyPropertyChanged notifiers on both fields as well, but the principle would be that when your real data is changed (MyData = newValue) then the dataobject would record the last transitions direction. And then you could base your decisions on that.
Earlier when i mentioned that the "datasource changed", I wasn't referring to the entire grid. I was just referring to the value of a particular cell that was changed....in which case the Cell.Tag will not be null right?
If you changed your datasource all the Cells should destroyed and recreated, so if you have the Tag value set then the datasource hasn't changed, just came and gone from view.
With the above code, the problem we have is not totally eliminated.
The issue is, if a cell was already rendered and then taken out of view and the datasource changed when the cell was out of view, and later brought back into view....
At this point, the CellControlAttached event fires but within the event (the e.Cell.Tag will not be null now) we still cannot determine if the datasource refresh triggered this event..
If there was a CellControlDetached event then we could have possibly set the e.Cell.tag to null again which would help us.
HI,
I am just following up on this thread.
Please let me know if you need further assistance.
Sincerely, MattDSE