This example shows how to use Windows. devices. sensors. The API of the compass. This example allows the user to view the compass reading as a magnetic-North, depending on the sensor installed, a true-North value. You can choose one or two schemes: • compass data event • Current compass reading Private Void Readingchanged ( Object Sender, compassreadingchangedeventargs E)
{
Dispatcher. invokeasync (coredispatcherpriority. Normal, (s, A) =>
{
Compassreading reading = (A. Context As Compassreadingchangedeventargs). Reading;
Scenario1output_magneticnorth.text = string. Format ( " {0.00} " , Reading. headingmagneticnorth );
If (Reading. headingtruenorth! = Null )
{
Scenario1output_truenorth.text = string. Format ( " {0.00} " , Reading. headingtruenorth );
}
Else
{
Scenario1output_truenorth.text = " No data " ;
}
}, This , E );
}
Complete example:/files/risk/windows8/examples card transmitter sample.rar