This project is read-only.

Animate removed items

Jun 10, 2010 at 10:53 AM

I'd like to enhance the AnimatedPanel class to achieve the same effect used by the Silverlight ContosoCars sample. I like their Look&Feel, but I don't like their implementation as it's not generic, not reusable and doesn't fit the WPF framework very well.

Any ideas on how to implement this?

Jul 4, 2010 at 12:41 PM


It will be difficult to implement such behaviour in AnimatedPanel itself because layout pass occurs _after_ some element has been removed. And since the collection of AnimatedPanel's elements does not contain removed item we can't animate it. It is possible to add tracking of removed elements by introducing another collection that will contain all visual children from previous layout pass. But this will result in a very complex code for AnimatedPanel as well as in decreased performance and increased memory usage.

I think that the better way to implement this is to use ObservableCollection<T> as an underlying collection for the items and listen to CollectionChanged event. Then if some elements were removed we may try to apply some animation. 

I'll try to show a sample of this in the next release. Stay in touch.

Thanks for the feedback!





Jul 6, 2010 at 11:29 AM


I've added code for animating removed items (see the latest change set 72184). Please note that code is not stable and may require some improvements.

Please feel free to ask me any questions.