PDA

Click to See Complete Forum and Search --> : [RESOLVED] Animating listbox items on load


chris128
Feb 25th, 2009, 03:21 PM
Hi Guys,

I would really like to be able to animate listbox items as they are loaded, so for example when the windows first opens the listbox items animate in (like fade in for example, or whatever animation I decide to use) but then also whenever they hit refresh to refresh the list, that same quick animation occurs again.
The thing is I have no idea how to do this as I dont know what I can hook into (either in XAML or in the code behind) that will be able to tell when the list items are loaded/reloaded.

Anyone got any suggestions? :)

Thanks
Chris

Pac_741
Feb 25th, 2009, 03:32 PM
Create a storyboard (if you have expression blend, that will make it easier) that will animate your items panel, or what ever you want to animate, then just use this code to play the storyboard on whatever event you want:


Storyboard Animation = this.FindResource("YourAnimationKey");
this.BeginStoryboard(Animation);

chris128
Feb 25th, 2009, 04:35 PM
yeah I know how to do that, the problem is finding an event that gets fired when the listbox items load

Actually I guess I could just manually play the animation in my routine that refreshes the listbox couldn't I. But would I animate each individual item in the listbox because I wouldnt be able to refer to each item by name in my code because they are databound to a collection. But then I also cant loop through the items in the collection and start the animations because when you loop through the items you dont get a reference to the controls/elements used to build the visual you just get a reference to the instance of the class that each item represents... if that makes sense

chris128
Aug 3rd, 2009, 08:12 AM
For anyone else who is trying to do the same thing - when I was playing around in Expression Blend the other day I noticed that there is a Loaded event for the listbox items (or it might have been the DataTemplate) so you just stick your storyboard in there and then hey presto :) all of the items animate when they load