How to apply accelerometer on a pivot page in WP7 to navigate the pivot pages?
Like when i tilt the phone to the right, i开发者_JAVA百科t will navigate the page to the right, and vice versa when i tilt it to the left.
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++
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.
protected override void OnOrientationChanged(OrientationChangedEventArgs e)
{
    switch (e.Orientation)
    {
        case PageOrientation.Portrait:
        case PageOrientation.PortraitDown:
        case PageOrientation.PortraitUp:
            contentPivot.SelectedIndex = 0;
            break;
        case PageOrientation.Landscape:
        case PageOrientation.LandscapeLeft:
        case PageOrientation.LandscapeRight:
            contentPivot.SelectedIndex = 1;
            break;
    }
}
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论