Book Image

Windows Phone 7.5 Application Development with F#

By : Lohith G N
Book Image

Windows Phone 7.5 Application Development with F#

By: Lohith G N

Overview of this book

Windows Phone is an OS which is also a platform in itself and provides an opportunity for application developers to build their apps and sell them on the Windows Phone Marketplace. Windows Phone is slowly catching up in the race with iOS and Android. Although well suited for scientific and mathematical calculations, the Windows Phone Platform provides an opportunity to program in F#. "Windows Phone 7.5 Application Development with F#"  focuses on making the user aware of Windows Phone App Development with the F# programming language in as short a time as possible. The book teaches you about the development environment, helps you understand the project structure, understand the controls, and ends with some of the cool features of the platform like sensors, launchers, and choosers. The book starts off with enabling the user with the right tools required to start developing. It focuses on getting the IDE ready, and project and item templates. By the end of the book the user will be familiarized with the different aspects of the platform itself. The transition from one chapter to another is short and focused so that you can get to the meat of the topic quickly.
Table of Contents (16 chapters)
Windows Phone 7.5 Application Development with F#
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
4
Windows Phone Screen Orientations
5
Windows Phone Gesture Events
7
Windows Phone and Data Access
Index

Accelerometer


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:

  1. Create a new project of the type F# Windows Phone Application (Silverlight) and give it a name.

  2. Right-click on the App project and add a reference to Microsoft.Devices.Sensors from the list.

  3. 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"
           ...