I’ve been searching all over for a solution, but found nothing that works.
The problem is simple:
- DataGrid (read-only) is bound to a collection of objects (implementing INotifyPropertyChanged)
- When certain properties of data objects change, the cell background should animate (eg. from Red to Transparent)
I’ve tried using styles with EventTrigger (TargetUpdated) to start a Storyboard, but it has side-effects, all cells’ background is animated when DataGrid is first populated, and also when it is scrolled or re-sorted.
I know there are few other similar questions, but I didn’t see a working solution.
Has anyone been able to achieve this? I’d very much prefer not to have any code-behind, but if it’s necessary, I’ll live with it…
EDIT:
I’ve noticed there is some confusion as to what I’m trying to achieve:
Let’s say a cell (and it’s underlying property on data object) has a value “A”. At some point it changes to “B” (e.g. update from a server). At this point the background should ‘flash’ (e.g. 1 second animation from Red to Transparent). At all other times the background should be Transparent.
I’ve been finally pointed in right direction on MS forum, the solution is to use attached behavior that registers OnTargetUpdated handler and starts s Storyboard. I’ve tried this approach earlier, but apparently one must start the Storyboard only if IsLoaded property of the cell is true. That gets rid of side effects I mentioned above.
Here is the link to the forum post.