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

Compass Orientation

The compass API uses a single axis to calculate the heading, depending on the orientation of the device. The device may be flat with its screen facing up, or it may be in an upright portrait position.

The Compass class does not provide the means to determine which orientation it is using; rather, you use an Accelerometer to tell you.

The viewmodel’s Start method also includes the initialization of an Accelerometer (see Listing 16.6).

LISTING 16.6. CompassViewModel.Start Method (excerpt 2)

public void Start(){    ...    accelerometer = new Accelerometer();    accelerometer.CurrentValueChanged += HandleAccelerometerCurrentValueChanged;    accelerometer.Start();}

The orientation of the compass ...

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