views:

160

answers:

3

Actually I'm using an items control and animating the childrens of it. The problem is when adding the items dynamically through Add() method the first item is not getting animated and just comes to display as usual.

I've planned to hide the dynamically added child and later make it visible when i want to use it with animation and that way i can bring it into view with animation.

To hide the child when it gets added dynamically i need some kinda of notification or event fired for Add() method!. I tried using InotifyCollectionChanged but that doesn't works.

Your thoughts please.. Your alternative suggestions are also appreciated..

Thanks in advance...

A: 

Hi Vinod.

First option is to check this question: Animate WPF Datatemplate when item added to Listbox?.

Another option would be to create your own ItemsControl and override OnItemsChanged() method. But it's not as easy as the first option.

Hope this helps.

Anvaka
hi Anvaka,Thanks for your response. I wont be able to use the first one and i already tried onItemsChanged(). I need some method or event which responds immediately after Add() method before rendering the added item in the UI
Vinod
A: 

Hi guys i found a solution for my problem, this may help you guys who are struck with such an issue.

This can be achieved by using a grid as your itemsHost and dynamically adding the children of itemscontrol to the grid and animating it. since the grid get its children only at the runtime we have more control over it and decide when i should be rendered on the screen.

Vinod
A: 

I'd probably bind the listbox to a collection in a ViewModel, and add directly to that rather than adding to the ListBox.

kyoryu