O'Reilly logo

Windows® Phone 8 Unleashed by Daniel Vaughan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the Accelerometer Class

Accelerometer, like the other sensor types, uses an event-based model for monitoring changes to sensor readings.

Note

Accelerometer contains a ReadingChanged event, which should not be used because it is a remnant of the first release of the Windows Phone OS and has been deprecated as of the 7.1 release of the SDK.

The event to use is the base class SensorBase event: CurrentValueChanged. Subscribing to the event can be done as follows:

var accelerometer = new Accelerometer();accelerometer.CurrentValueChanged += HandleSensorValueChanged;accelerometer.Start();

When the CurrentValueChanged event is raised, the event handler receives a SensorReadingEventArgs<AccelerometerReading> object, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required