Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Animate row disappearance in WPFToolKit DataGrid

I have downloaded WPFToolkit, and I am using the DataGrid provided in this package. I am trying to animate a row disappearance when the row is removed, but I don't know how to do it. Does anyone know how it can be done?

like image 772
Andy Avatar asked Apr 29 '09 22:04

Andy


1 Answers

This is the kind of thing that can be tricky in WPF--though your boss will think it should be easy--since WPF is supposed to enable animation and striking visuals. After all, there are all kinds of awesome Silverlight/WPF demos on the web that look great and really sell the tech. Of, course what your boss doesn't know is that those demos were written just to show off the easy, flashy features. Things that are a bit different than standard, however, have a nasty way of being very difficult.

But enough ranting, I'll give you a possible approach, though there may be a far better one:

Let's assume you've bound the DataGrid to some kind of collection, and for sake of argument let's assume its a list of Foo objects, i.e. List<foo> MyFoos. Then you could add a property to the FOO class called BeingDeleted. Then in the template for your DataRowView, trigger on this property to begin a storyboard that animates a fade-out or collapse of that particular row. This is kind of gross, since it implies adding a property to the Foo object that might have nothing to do with it otherwise. You could alternatively create a special wrapper or sub-class of Foo.

like image 198
PeterAllenWebb Avatar answered Oct 17 '22 04:10

PeterAllenWebb