About 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.

Publication date:
April 2013


Chapter 1. Setting up Windows Phone Development with F#

In this chapter, we will try to understand the three important aspects that make up Windows Phone Development using F# (pronounced as F sharp), namely:

  • What is Windows Phone?

  • What is F#?

  • Prerequisites for development

We will go over these aspects, one by one in the coming sections.


What is Windows Phone?

Windows Phone is the new mobile operating system from Microsoft Corporation and was launched in October 2010. After the initial release, there were a series of updates to Windows Phone with the recent one being Windows Phone 7.5 (Mango).

Windows Phone has the tagline "Put people first", and is mainly aimed at consumers or end users. Windows Phone is the successor to a previous version of mobile operating system from Microsoft known as Windows Mobile. Windows Mobile was an operating system designed around the Windows CE (Compact Edition) kernel. Windows Phone, being a new platform written from scratch, is not compatible with the earlier versions of Windows Mobile, that is, it does not support backward compatibility. So applications written for Windows Mobile won't run on Windows Phone. Windows Phone and Windows CE are just two different mobile platforms available at present from Microsoft.

Windows Phone has a fresh and new user interface called Modern UI , a typography-based design language that is inspired by the transport system.

Windows Phone – a standardized platform

The biggest problem that application developers for mobile platforms faced was the varied range of development environments they had to adapt to. The mobile development environment was completely different from those compared to either a desktop application development environment or a web application development environment. Though some development environments like Microsoft Platform, which includes developing using the popular Integrated Development Environment (IDE) Visual Studio and languages like Visual C++ or Visual C# were, to some extent, similar.

But, one had to face the challenges of handling different form factors, device capabilities, hardware differences, and other incompatibilities. With Windows Phone, Microsoft has made sure that it provides a common design and a common set of capabilities for devices from many different manufactures. So be it any device from any manufacturer, as a developer we only have one set of design and capabilities to tackle. This makes it easier for the developers to concentrate on their application and not worry about any other nuances.

Microsoft has set minimum requirements for the hardware on which the Windows Phone runs. The hardware requirements are as follows:

  • Capacitive touch: Four or more contact points

  • Sensors: GPS, accelerometer, compass, light, proximity

  • Camera: 5 MP or more, Flash, dedicated camera button

  • Memory: 256 MB, 8 GB flash storage or more

  • GPU: DirectX 9 acceleration

  • Processor: ARMv7 Cortex/Scorpion or better

  • Screen sizes: 480 x 800 WVGA, 480 x 320 HVGA

  • Keyboard : Optional

  • Hardware buttons: Must be fixed on the face

The following image from http://msdn.microsoft.com/en-us/library/gg490768.aspx shows the various features a Windows Phone has to offer for both developers as well as consumers:

Windows Phone features

Development option for Windows Phone

Windows Phone Application Platform is built on the existing Microsoft tools and technologies, such as Visual Studio, Expression Blend, Silverlight, and XNA Framework. The learning curve for developing Windows Phone Application is minimal for anyone who is familiar with the tools and technologies on which the platform is built. Windows Phone Application Platform provides two main frameworks for development. They are:

  • Silverlight Framework – used for event-driven, XAML-based applications. This framework allows developing markup-based and rich, media-based applications.

  • XNA Framework used for loop-based games. Allows developing immersive and fun gaming- and entertainment-based applications.

Windows Phone Application Platform Architecture

The platform itself is made up of four main components. The following figure from http://i.msdn.microsoft.com/dynimg/IC513005.jpg shows the components of Windows Phone Application Platform:

Windows Phone Application Platform

In this figure we have:

  • Runtimes: Silverlight, XNA Framework, and phone-specific features provide the environment to build graphically-rich applications

  • Tools: Visual Studio, Expression Blend, and related tools provide developer experience to create, debug, and deploy applications

  • Cloud Services: Azure, XBOX Live, notification services, and location services provide data sharing across cloud and a seamless experience across the devices a consumer will use

  • Portal Services: Windows Phone Marketplace allows developers to register, certify, and market their applications

The components of interest for any developer are runtime and tools. Runtime because that's the base on which applications are developed. Tools play another major part in the development experience. Visual Studio and Expression Blend try to enhance the development experience by providing features that makes a developer's job easy while developing. Visual Studio in particular is a well-known IDE, which lets you create, debug, and deploy an application without having to go out of the IDE.

All phases of the development can be achieved staying within the IDE and this is the biggest experience one gets when on this platform. Expression Blend makes visual designing very easy as it allows the drag-and-drop capability on the design surface. When designing in Blend, you just set a bunch of properties and the code is automatically written by the Blend for you.


What is F#?

F# is a .NET programming language. F# was initially started as a research project at Microsoft Research Lab by Don Syme. Later, it became a mainstream .NET programming language and is distributed as a fully supported language in the .NET Framework as part of Visual Studio.

According to Microsoft Research, F# is:

A succinct, expressive, and efficient functional and object-oriented language for .NET that helps you write simple code to solve complex problems.

F# is a strongly typed language; it uses the type inference. Since it uses the type inference, programmers need not declare the data types explicitly. The compiler will deduce the data type during compilation. F# will also allow explicit declaration of data types.


Prerequisites for development

To start developing for Windows Phone using F# as a language, you will need some prerequisites to be installed on your development system. The prerequisites are as follows:

  • Visual Studio 2010

  • Windows Phone Software Development Kit 7.1

  • Windows Phone Project and Item Templates for F#

So let's take a look at these one by one.

Visual Studio 2010

When you install Visual Studio 2010 (Professional or Ultimate) and choose the default options during installation, the installer will, by default, install Visual C#, Visual C++, Visual Basic, and Visual F#. This is by far the easiest way of starting to develop with F#.

Windows Phone Software Development Kit 7.1

The Software Development Kit (SDK) provides us with the tools needed to develop applications and games for the Windows Phone platform. The SDK can be downloaded from http://gnl.me/WPSDK71. The SDK installs the following components on your development system:

  • Microsoft Visual Studio 2010 Express for Windows Phone

  • Windows Phone Emulator

  • Windows Phone SDK 7.1 Assemblies

  • Silverlight 4 SDK and DRT

  • Windows Phone SDK 7.1 Extensions for XNA Game Studio 4.0

  • Microsoft Expression Blend SDK for Windows Phone 7

  • Microsoft Expression Blend SDK for Windows Phone OS 7.1

  • WCF Data Services Client for Window Phone

  • Microsoft Advertising SDK for Windows Phone

Windows Phone project and Item Templates for F#

The easiest way to get up and running is to utilize one of the project templates available through the Visual Studio Gallery. These templates have been created by the F# community and they provide a great way to kick-start your project. Daniel Mohl, an F# Most Valuable Professional (MVP) has written a couple of Visual Studio templates that will help us to quickly get up and running with Windows Phone development using F#. You can download any of the following available templates based on your needs. The templates and URL from where you can download them is as follows:



In this chapter you learned about Windows Phone as a new mobile platform. We looked at how Windows Phone Application Platform offers a standardized platform for developers. We also looked at several features that Windows Phone provides.

Then we looked at a new functional programming language in .NET framework called F#. F#, which started in Microsoft Research Lab is now a mainstream .NET programming language.

After understanding Windows Phone as a platform and F# as a language, we then looked at the prerequisites that are required for developing applications for Windows Phone using F# as the language.

In the next chapter we will take a look at the different project templates we downloaded. We will go in depth into each project and understand the various components of each project.

About the Author
  • Lohith G.N.

    Lohith G. N. who hails from Mysore, India and currently residies in Bangalore, India has over 12 years of software development experience. Currently he works as developer evangelist for Telerik in India and takes care of evangelism for the South Indian region. Lohith comes from a production engineering background and ended up in software development thanks to the FORTRAN language that he learnt during his graduation days. Well versed with the .NET platform, Lohith has experience building web applications, Windows applications, and service-oriented architecture. Lohith has spent close to a decade mostly in the services-based industry and is well versed with the agile method of software development.

    Lohith is also a two time Microsoft Most Valuable Professional (MVP) in the area of ASP.NET/IIS. He was awarded this prestigious award from Microsoft in 2011 and 2012. Lohith often writes on ASP.NET/ODATA and maintains his own blog at http://kashyapas.com. He can be reached on Twitter and his Twitter handle is @kashyapa. To know more about Lohith you can check out http://about.me/kashyapa. Lohith is also one of the user group leads for the Bangalore DotNet user group – one of the most active user groups in India. He is a regular speaker at his local user groups.

    Browse publications by this author
Windows Phone 7.5 Application Development with F#
Unlock this book and the full library FREE for 7 days
Start now