是否有任何类似于OnOrientationChanged的方法?

时间:2011-03-30 13:43:07

标签: c# silverlight windows-phone-7 orientation

是否有protected override void OnOrientationChanged(OrientationChangedEventArgs e)的方法在SupportedOrientations="Portrait"

时有效

我要做的是实现一些手势,如:

  • 用户将手机旋转到横向左侧位置并执行一些代码
  • 用户将手机旋转到横向右侧位置并执行另一个代码

我的应用是以PortraitUp为导向的。当我设置SupportedOrientations="PortraitOrLandscape"时,内容开始旋转。

或者我应该使用加速计来处理手机位置?

2 个答案:

答案 0 :(得分:3)

听起来你是在加速度计之后,在Codeplex上可用的助手很少,这可能会让你站起来:

http://accelerometer.codeplex.com/ - 用于了解加速度计发生情况的视觉辅助工具 http://phone7actionpack.codeplex.com/ - 包括手机旋转时改变视觉状态的行为。

答案 1 :(得分:2)

这听起来像是在“OnOrientationChangedToLandscapeLeft”类型事件(和类似事件)之后。
这不存在,但你可以用现有的东西自己创建。

OnOrientaionChanged事件中,您可以通过检查e参数然后相应地执行相关代码来检测屏幕的旋转方式。
类似的东西:

if (e.Orientation == PageOrientation.LandscapeLeft)
{
    // Do whatever you want to here
}
else if (e.Orientation == PageOrientation.LandscapeRight)
{
    // Do something else here
}
else
...
相关问题