-
Book Overview & Buying
-
Table Of Contents
Windows Phone 7.5 Application Development with F#
By :
An accelerometer is a sensor that can measure the intensity and direction of the acceleration force that the phone experiences. The intensity reading is provided as a decimal value ranging from -1.0 to 1.0 for the X, Y, and Z axes on the phone. This sensor monitors the acceleration force experienced width-wise, length-wise, and depth-wise. In order to detect the direction of force, the X, Y, and Z values must be compared to one another.
Let's create a demo app to understand how to use the accelerometer sensor:
Create a new project of the type F# Windows Phone Application (Silverlight) and give it a name.
Right-click on the App project and add a reference to Microsoft.Devices.Sensors from the list.
In MainPage.xaml, add three text blocks to display the X, Y, and Z reading. The XAML snippet for the same is shown as follows:
<TextBlock Height="30" HorizontalAlignment="Left"
Margin="20,100,0,0" Name="xTextBlock"
Text="X: 1.0" VerticalAlignment="Top"
...
Change the font size
Change margin width
Change background colour