I am trying to use VisualStateManager inside a Panorama control but it is not working.
XAML
<phone:Panorama x:Name="Pano">
<phone:PanoramaItem x:Name="PanoItem">
<StackPanel x:Name="Stack">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="VisualStateGroup">
<VisualState x:Name="Normal">
<Storyboard>
<DoubleAnimation Duration="0:0:0.600"
To="90"
Storyboard.TargetProperty="RotationY"
Storyboard.TargetName="plane"
d:IsOptimized="True">
</DoubleAnimation>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<Button Content="some text"
x:Name="ToFade">
<Button.Projection>
<PlaneProjection x:Name="plane" />
</Button.Projection>
</Button>
<Button Content="Change"
Click="Button_Click" />
</StackPanel>
</phone:PanoramaItem>
</phone:Panorama>
Code behind
private void Button_Click( object sender, RoutedEventArgs e ) {
var result = VisualStateManager.GoToState(this, "Normal", true);
}
The strange part is that if I take the <StackPanel>
off of <Panorama>
the state change works like a charm.
This Works:
<!--<phone:Panorama x:Name="Pano">
<phone:PanoramaItem x:Name="PanoItem">-->
<StackPanel x:Name="Stack">
... rest same code as above ...
</StackPanel>
<!--</phone:PanoramaItem>
</phone:Panorama>-->
I have tried passing other controls to the VisualStateManager.GoToState()
like this
, this.Pano
, this.PanoItem
but without success. Can someone explain what is wrong? and Why?