tags:

views:

83

answers:

1

I have an ItemsControl that shows items using DataTemplates. When certain properties of the items change, I would like the changes to appear animated in the ItemsControl. For instance, an item has a Thickness and a Color and when these properties change, I would like to show an animation transitioning from one to the other. What is the easiest way to do this?

+1  A: 

I think you could do this through using a Trigger's EnterActions and ExitActions.
You could use these with a standard trigger if the properties are a part of the control, or with a DataTrigger if the properties exist on the Items that you are templating. While they need a set value for the Value property to fire the actions, you can use a ValueConverter or a MultiValueConverter to transform your values to something more useable by the triggers.

rmoore
Okay, so let's say a property changes from 13.7 to 5.9. It's not clear what to use for the Trigger's Value property, or what the properties of the DoubleAnimation should be to cause an animation from 13.7 to 5.9.
Qwertie
For the Values I think Converters work great, you can catch a bunch of ranges and return a status like if it changes by <5 return SmallChange and if it returns by 50 return HugeChange, then the triggers Values are set to occur on SmallChange and HugeChange.If you are trying to animate the actual property, not some form of visual, then that is something totally diffrent. I'm sorry if I didn't understand that that's what you were going for. You might want to take a look at this: http://joshsmithonwpf.wordpress.com/2009/04/25/orchestrating-animated-transitions-between-view-and-viewmodel/
rmoore