快照视图地铁应用程序的问题

时间:2013-10-01 10:12:11

标签: c# windows windows-store-apps

嘿伙计们请帮助解决我的问题,我已经制作了一个应用程序,我必须将其上传到Windows商店,但问题是它不支持快照视图。我希望它不应该在捕捉视图中工作,当应用程序进入快照视图时,它只显示消息“切换到全屏”。请告诉我如何编写代码以及在XAML或XAML.cs中编码的位置。提前致谢。

2 个答案:

答案 0 :(得分:0)

可能的解决方案之一

  1. 创建一个您想要用于Snap的新页面
  2. 收听用户点按应用时引发的事件。
  3. 导航至具有“切换到全屏”
  4. 的页面
  5. 收听用户取消隐藏时引发的事件
  6. 返回原始页面
  7. 要实现这一目标,

    在OnLaunched事件的App.xaml.cs中写下这个

     Window.Current.SizeChanged += Current_SizeChanged;
    

    现在为事件处理程序

     void Current_SizeChanged(object sender, Windows.UI.Core.WindowSizeChangedEventArgs e)
        {
            ApplicationViewState viewState = ApplicationView.Value;
           if (viewState == ApplicationViewState.Snapped)
            {
                //Navigate to the new common snap page
            }          
          else{
                  //Write the code to check if the previous state was snapped and then navigate back
            }
       }
    

答案 1 :(得分:0)

添加基本页面并将XAML替换为:

<common:LayoutAwarePage
    x:Name="pageRoot"
    x:Class="App1.OopsPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:App1"
    xmlns:common="using:App1.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid>
        <!-- Full screen content. -->
        <Grid x:Name="FullScreenGrid">
            <TextBlock>Here is your content.</TextBlock>
        </Grid>

        <!-- Snapped view content. -->
        <Grid x:Name="SnappedViewGrid" Visibility="Collapsed">
            <TextBlock>Please go back to full screen :(</TextBlock>
        </Grid>

        <VisualStateManager.VisualStateGroups>

            <!-- Visual states reflect the application's view state -->
            <VisualStateGroup x:Name="ApplicationViewStates">
                <VisualState x:Name="FullScreenLandscape"/>
                <VisualState x:Name="Filled"/>
                <VisualState x:Name="FullScreenPortrait" />

                <!-- The back button and title have different styles when snapped -->
                <VisualState x:Name="Snapped">
                    <Storyboard>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="FullScreenGrid" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/>
                        </ObjectAnimationUsingKeyFrames>
                        <ObjectAnimationUsingKeyFrames Storyboard.TargetName="SnappedViewGrid" Storyboard.TargetProperty="Visibility">
                            <DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/>
                        </ObjectAnimationUsingKeyFrames>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
    </Grid>
</common:LayoutAwarePage>

确保将App1替换为您的app命名空间,并且 Common 文件夹中必须包含 LayoutAwarePage.cs