Hassaan Nasir

Hassaan Nasir

  • NA
  • 5
  • 4.2k

Snapped View in Windows 8 Store App Xaml/C++

Aug 20 2014 2:47 AM
I am making a Windows App in c++ in which i want to use Snap View. I used my C# code and transform it into C++ but it didn't work. But it's working in c#. Here is my Xaml Code

<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup>

<VisualState x:Name="Snapped">
<Storyboard>

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SnappedGrid" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
</ObjectAnimationUsingKeyFrames>

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="MainGrid" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>

</Storyboard>
</VisualState>


<VisualState x:Name="FullScreen">
<Storyboard>

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="SnappedGrid" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
</ObjectAnimationUsingKeyFrames>

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="MainGrid" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
</ObjectAnimationUsingKeyFrames>

</Storyboard>
</VisualState>

</VisualStateGroup>
</VisualStateManager.VisualStateGroups>



<Grid x:Name="SnappedGrid" Visibility="Collapsed" Margin="0,0,0,0" Background="#FF16201F">

<StackPanel VerticalAlignment="Center">
<Image Height="704" Source="Assets/SplashScreen.png" VerticalAlignment="Center"/>
<TextBlock Text="Please run in FullScreen mode to continue" HorizontalAlignment="Center" FontSize="25" Foreground="White"/>
</StackPanel>
</Grid>
<Viewbox>
<Grid Name="MainGrid" Width="1096" Visibility="Visible">
</Grid>
</ViewBox>
</Grid>



And Here is my C++ Code

void Main_Menu::Current_SizeChanged(Object^ sender, WindowSizeChangedEventArgs^ e)
{
if (Window::Current->Bounds.Width <= 875)
{
VisualStateManager::GoToState(this, "Snapped", true);
}
else
{
VisualStateManager::GoToState(this, "FullScreen", true);
}
}

Now please tell me where i am wrong?Do i have to add something in 'Main_Menu(){}' function?? Because it runs perfectly in c#