如何在 WP7 中的枢轴页面上应用加速度计来导航页面?
如何在 WP7 中的枢轴页面上应用加速度计来导航枢轴页面?
就像当我向右倾斜手机时,它会将页面导航到右侧,反之亦然,当我向左倾斜手机时。
How to apply accelerometer on a pivot page in WP7 to navigate the pivot pages?
Like when i tilt the phone to the right, it will navigate the page to the right, and vice versa when i tilt it to the left.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可以通过处理 AccelerometerReadingChanged 事件来检测加速度计读数,如 MSDN 中所述:
http://msdn.microsoft.com/en-us/library/ff604984.aspx
然后,您需要对以下值应用某种阈值:在事件参数中返回。当超过合适的阈值时,增加或减少枢轴索引,即
pivot.SelectedIndex++
The accelerometer readings can be detected by handling the
AccelerometerReadingChanged
event as described in MSDN:http://msdn.microsoft.com/en-us/library/ff604984.aspx
You then need to apply some sort of threshold to the values that are returned in the event arguments. When a suitable threshold has been exceeded, increment or decrement in the pivot index, i.e.
pivot.SelectedIndex++
虽然 ColinE 建议的方法无疑会起作用,但它有点混乱。您必须自己计算阈值,并且从传感器获得的读数比您需要的水平低得多。
我建议使用 Page 控件支持的 OrientationChanged 事件。
While the approach ColinE suggested would undoubtedly work, it's somewhat messy. You'd have to calculate the threasholds yourself and you're getting a much lower level reading off the sensor than what you need.
I would suggest using the OrientationChanged event supported by the Page control.