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

问题描述

|
  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++;
                    }  

                }
            })
    

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...