通过加速度计错误枢轴导航页面

|
  void OnAccelerometerReadingChanged(object sender, AccelerometerReadingEventArgs args)
        {
            Dispatcher.BeginInvoke(() =>
                 {
                     if (args.X > 1.0f)
                     {

                         if (contentPivot != null)
                         {
                             if (contentPivot.SelectedIndex >= contentPivot.Items.Count - 1) contentPivot.SelectedIndex = 0;
                             contentPivot.SelectedIndex++;
                         }

                     }

                     if (args.X < -1.0f)
                     {

                         if (contentPivot != null)
                         {
                             if (contentPivot.SelectedIndex >= contentPivot.Items.Count - 1) contentPivot.SelectedIndex = 0;
                             contentPivot.SelectedIndex--;
                         }

                     }



                 });
        }
我收到错误消息“ SelectedIndex。”,它在
contentPivot.SelectedIndex--;
行中指示。 此代码的目的是允许用户在我将其侧向倾斜时导航到下一个枢纽页面。 如果我确实错了,请更正我的代码。     
已邀请:
        如果您没有权限,则听起来好像您尚未启用
Sensor
功能。在
Solution
中,转到
Properties
文件夹并打开
WMAppManifest.xml
。然后在
<Capabilities>
标签内,添加以下内容:
<Capability Name=\"ID_CAP_SENSORS\"/>
(该解决方案将贷记给键盘P)再次编辑: Dispatcher.BeginInvoke(()=>
            {
                if (args.X > 0.5f)
                {

                    if (contentPivot!= null)
                    {
                        if (contentPivot.SelectedIndex >= contentPivot.Items.Count - 1) contentPivot.SelectedIndex = 0;
                        contentPivot.SelectedIndex++;
                    }  

                }
            })
    

要回复问题请先登录注册