开发者

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 W开发者_开发百科PF ( 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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜