C# 快照查看地铁应用程序的问题
嘿,伙计们,请帮助解决我的问题,我已经制作了一个应用程序,我必须上传到windows应用商店,但问题是它不支持快照视图。我希望它不应该在快照视图中工作,当应用程序进入快照视图时,它只会显示一条消息“切换到全屏”。请告诉我如何编码,以及在XAML或XAML.cs中编码的位置。提前谢谢 可能的解决方案之一C# 快照查看地铁应用程序的问题,c#,windows,windows-store-apps,C#,Windows,Windows Store Apps,嘿,伙计们,请帮助解决我的问题,我已经制作了一个应用程序,我必须上传到windows应用商店,但问题是它不支持快照视图。我希望它不应该在快照视图中工作,当应用程序进入快照视图时,它只会显示一条消息“切换到全屏”。请告诉我如何编码,以及在XAML或XAML.cs中编码的位置。提前谢谢 可能的解决方案之一 创建要用于快照的新页面 聆听用户捕捉应用程序时引发的事件 导航到“切换到全屏”页面 收听用户取消睡眠时引发的事件 返回到原始页面 为此, 在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
}
}
添加基本页面并用以下内容替换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
,并且您的公用文件夹中必须有LayoutAwarePage.cs