public Welcome_2()
{
InitializeComponent();
Accelerometer acc = new Accelerometer();
acc.TimeBetweenUpdates = TimeSpan.FromMilliseconds(5);
acc.CurrentValueChanged += new EventHandler<SensorReadingEventArgs<AccelerometerReading>>(accEventHandler);
acc.Start();
}
private void accEventHandler(object sender, SensorReadingEventArgs<AccelerometerReading> e)
{
Vector3 accelReading = new Vector3();
accelReading.X = (float)e.SensorReading.Acceleration.X;
accelReading.Y = (float)e.SensorReading.Acceleration.Y;
accelReading.Z = (float)e.SensorReading.Acceleration.Z;
if (accelReading.X > 0 || accelReading.X < 0)
{
NavigationService.Navigate(new Uri("/Get_Insert.xaml", UriKind.Relative));
}
}
答案 0 :(得分:0)
要使用传感器(加速度计),请将Microsoft.Devices.Sensors和Microsoft.Xna.Framework引用添加到项目中。 还要确保在项目的“属性”文件夹下的应用清单文件的功能中选中了ID_CAP_SENSORS功能。