Hey all, I'm trying to apply an animation to any element that gets added to a datatemplate in WP7's subset of silverlight. I'm having some issues though. While it appears to be quite possible in WPF ( Animate WPF Datatemplate when item added to Listbox? ) using DataTemplate.Triggers, WP7's silverlight doesn't have the Triggers property for DataTemplates. As such, how would I go about doing this on the winphone?
I am assuming you have a DataTemplate
that is used as the ListBox.ItemTemplate
property value in XAML? If this is the case, you should be able to handle the Loaded
event on the root element of the DataTemplate
in code behind. This event will be invoked as each DataTemplate
'instance' is created, alowing you to fire a Storyboard
.
Silverlight 4 added the concept of LayoutStates to the ListBoxItem control, this allowed you add animations for state transitions including things like BeforeLoaded to AfterLoaded. Sadly this functionality isn't baked into WP7 (based on Silverlight 3).
There are some workarounds till that changes with the "Mango" release, including the solution ColinE mentions.
Some resources are: Animate your #WP7 ListBoxItems while being un-/loaded and Reactive Extensions #3: Windows Phone 7
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With