I wrote an extremely simple style that I thought would animate an item's removal from a XamDataGrid. Here is my style:
<Style TargetType="{x:Type igDP:DataRecordPresenter}" x:Key="DataRecordPresenterStyle"> <Style.Triggers> <EventTrigger RoutedEvent="FrameworkElement.Unloaded"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="00:00:01" To="0" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Style.Triggers> </Style>
I'm not sure why it doesn't work. I suspect that the Unloaded handler isn't getting invoked when I remove the item. By the way I am data binding my XamDataGrid to an ObservableCollection of Device objects (my class). I just call devices.Remove to remove the item. I'm guessing that the items Unloaded handler isn't getting called but I can't be sure as I can't debug the XAML.
Is there a way to animate an item removal from XamDataGrid.
Ideally, I would want to animate the Height value until the item is zero but a fade will work OK as well.
Please see my attached project for a non-working attempt.
Thanks
Louis
Hello Louis,
Thank you for your feedback. I am glad that you resolved your issue and I believe that other community members may benefit from this as well.
Thanks again.
That works perfectly and you put the code in the viewmodel as well so you get bonus points!
Thanks.
Thank you for your post. I have been looking into it and I modified your sample project, so now it has the functionality you want. Basically I created a class that implements ICommand interface in order to use the CommandParameter Property. This way I was able to get the XamDataGrid in the Execute method. There I firstly run the animation and in its completed event I remove the DataItem from the DataSource. I also set a ScaleTransform to the DataRecordPresenter in order to be able to animate the ScaleY value, because the Height Property is dynamic and its value is Double.NAN. Please let me know if this helps you or you have further questions on this matter.
Looking forward for your reply.