开发者

Is it possible to change a ListBox' ItemTemplate from a Storyboard?

开发者 https://www.devze.com 2023-03-11 11:45 出处:网络
I have a behavior that changes the visual state based on the page\'s orientation (portrait/landscape). I have a ListBox with a somewhat complex DataTemplate for its ItemTemplate. Is it possible to cha

I have a behavior that changes the visual state based on the page's orientation (portrait/landscape). I have a ListBox with a somewhat complex DataTemplate for its ItemTemplate. Is it possible to change the ItemTemplate from a VisualState's Storyboard? My XAML karma is low, and Blend doesn't let me do it (it changes the ori开发者_开发问答ginal ItemTemplate, it doesn't add a storyboard entry).

And remember, this is for Windows Phone 7 (thus Silverlight 3).


I probably didn't get an answer because it was too obvious. I told you my XAML karma was low. Here is the solution. Simply add this ObjectAnimationUsingKeyFrames to your storyboard:

<ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(ItemsControl.ItemTemplate)" 
                               Storyboard.TargetName="PartakersListBox">
    <DiscreteObjectKeyFrame KeyTime="0" 
                            Value="{StaticResource LandscapePartakerDataTemplate}" />
</ObjectAnimationUsingKeyFrames>

I didn't return to Blend yet, to see if the template was editable. Will update below.

0

精彩评论

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