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

    Question

  • 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?? Beacause it runs perfectly in c#

     
    Wednesday, August 20, 2014 6:38 AM

Answers

  • I have solved it. Thanx for the reply sir! I just put the 'Current_SizeChanged' event's code into Page_SizeChanged event and it worked.
    Saturday, August 23, 2014 2:34 PM

All replies

  • In what way is it not working? Does your size changed handler not get called? Does it get called but not have a proper effect?

    If it isn't called, is it wired up?

    Can you provide a minimal sample on your OneDrive that demonstrates the problem?

    Wednesday, August 20, 2014 1:22 PM
    Moderator
  • I have solved it. Thanx for the reply sir! I just put the 'Current_SizeChanged' event's code into Page_SizeChanged event and it worked.
    Saturday, August 23, 2014 2:34 PM