1
votes

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 original ItemTemplate, it doesn't add a storyboard entry).

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

1

1 Answers

1
votes

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.