WP7 (Windows Phone 7) 在 XAML 或 C# 中锁定手机方向
Windows Phone 7 是否可以手动锁定手机方向? 因为我使用加速度计来处理具有固定 UI 的按钮旋转。
我已经尝试过:
在 XAML
SupportedOrientations="Landscape" Orientation="LandscapeLeft"
OrientationChanged="PhoneApplicationPage_OrientationChanged"
和后面的代码中:
private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
{
//Orientation locking
//Do nothing
}
但 UI 仍在左横向和右横向之间切换...
谢谢。
Is it possible to manualy lock the phone orientation in Windows phone 7 ?
Because I'm using the accelerometer to handle buttons' rotation with a fixed UI.
I've tried that :
In the XAML
SupportedOrientations="Landscape" Orientation="LandscapeLeft"
OrientationChanged="PhoneApplicationPage_OrientationChanged"
And in the code behind :
private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
{
//Orientation locking
//Do nothing
}
But the UI is still shifting between landscape left and landscape right...
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
无法阻止 LandscapeLeft 和 LandScapeRight 之间的移动。这是设计使然。
作为解决方法,您可以在 OnOrientationChanged 中手动旋转/转换 UIElement,以便用户看不到差异。
我使用这种技术来防止“背景”图像看起来旋转,无论方向如何,但然后有一个单独的控件,它看起来像弹出窗口,但它确实响应图像顶部显示的方向变化。
There is no way to prevent the shifting between LandscapeLeft and LandScapeRight. This is by design.
As a work around, you can manually rotate/transform your UIElements in the OnOrientationChanged so that the user doesn't see a difference.
I've used this technique to keep a "background" image from appearing to rotate regardless of orientation but then having a separate control which appears like a popup but which does respond to orientation changes show on top of the image.
您好,我通过重写 OnOrientationChanged 方法找到了解决方案。这对我有用。这不会影响系统托盘和应用程序菜单,但页面保持所选方向。
Hi I found a solution by overriding OnOrientationChanged method. It works for me. That do not affect system tray and application menu, but page stay in the selected orientation.
在
MainPage()
构造函数中的InitializeComponent();
之后添加此this.SupportedOrientations = SupportedPageOrientation.Portrait;
以锁定纵向模式下的方向。它对我来说效果很好。add this
this.SupportedOrientations = SupportedPageOrientation.Portrait;
afterInitializeComponent();
inMainPage()
constructor to lock the orientation in Portrait mode. It works fine for me.