jjcm
jjcm

Reputation: 219

Animate WP7 datatemplate element when first added to listbox

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?

Upvotes: 5

Views: 989

Answers (2)

Nigel Sampson
Nigel Sampson

Reputation: 10609

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

Upvotes: 2

ColinE
ColinE

Reputation: 70142

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.

Upvotes: 3

Related Questions