问题描述
|
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++;
}
}
})