I have a Page with a Grid containing two columns, the first contains a button which toggles the visibility of the second (via a ViewModel binding). How can I add an animation for showing/hiding the second column (with Pivot as content) to this scenario?
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0">
<Button Command="{Binding TogglePivot}"/>
</Grid>
<Pivot x:Name="Content_Pivot" Grid.Column="1">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>
<!-- Hidden state -->
<VisualState x:Name="Hidden">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content_Pivot" Storyboard.TargetProperty="Width">
<DiscreteObjectKeyFrame KeyTime="0" Value="0"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
<!-- Visible state -->
<VisualState x:Name="Visible">
<Storyboard>
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content_Pivot" Storyboard.TargetProperty="Width">
<DiscreteObjectKeyFrame KeyTime="0" Value="600"/>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<interactivity:Interaction.Behaviors>
<!-- Show -->
<core:DataTriggerBehavior Binding="{Binding IsVisible}" ComparisonCondition="Equal" Value="True">
<core:GoToStateAction StateName="Visible"/>
</core:DataTriggerBehavior>
<!-- Hide -->
<core:DataTriggerBehavior Binding="{Binding IsVisible}" ComparisonCondition="Equal" Value="False">
<core:GoToStateAction StateName="Hidden" />
</core:DataTriggerBehavior>
</interactivity:Interaction.Behaviors>
<!-- Content.. -->
</Pivot>
</Grid>
The above works fine, but only on the first toggle of the visibility of the Pivot. Subsequent toggles do not show the animation..
Any easy way of achieving this without manually invoking Storyboards?
Thanks.
==EDIT==
I made some changes to above code (namely, added VisualStates and DataTriggerBehaviour).
Still can't get it to work... Any ideas?