c# - 在 Windows 8 中处理方向

标签 c# xaml windows-8 microsoft-metro

想要创建一个 Metro Style Windows 8 应用程序,该应用程序不旋转根 Grid,所有内容都处于 Portrait 模式。我想在 CodeVisual States 中处理方向,但现在当我旋转设备时,所有内容都会自动旋转并填充新的宽度和高度。

如何禁用此旋转行为,即禁用 Portrait 方向,但仍然能够获取有关方向更改的事件?

此外,Windows.Graphics.Display.DisplayProperties.AutoRotationPreferences 似乎不起作用

最佳答案

双击 Metro 应用项目中的“Package.appxmanifest”文件,您应该会看到应用的配置。在“Application UI”页面中,您可以在中间找到“Supported rotations”。您可以勾选您支持的模式,不要勾选“人像”模式。然后您的应用将不会再收到任何“纵向​​”模式事件。

如果您编写自己的 appx list ,则可以在部分下添加以下 block ,如下所示

    <InitialRotationPreference>
      <Rotation Preference="landscape" />
      <Rotation Preference="portraitFlipped" />
      <Rotation Preference="landscapeFlipped" />
    </InitialRotationPreference>

关于c# - 在 Windows 8 中处理方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10260042/

相关文章:

c# - 选择部分显示的 WPF 复选框

xaml - Visual Studio 2015 xaml 设计模式未处理的异常

windows-8 - 使 "Uninstall"命令为 Windows 8 应用程序做正确的事情

windows - 为自动测试禁用 Windows 防火墙弹出窗口

c# - 当服务器返回错误时,有什么方法可以使用 WebClient 访问响应主体?

xaml - 属性内容为null或IEnumerable

c# - ASP.NET DatePicker 在 GridView 中不工作

.net - WinRT C# Metro Play MediaElement 异步

c# - 单独线程中的多个表单

c# - 处理 DisposeAsync 中异常的正确方法