Microsoft
did not invent any new languages or frameworks for the Windows Phone
application platform. The company simply adapted its existing
frameworks. This means that you will be able to program using C# with .NET Framework.
What .NET provides is a common base class library that every Microsoft
.NET programmer will be familiar with, including support for
multithreading, XML, Linq, collections, events, data, exceptions, IO,
service model, networking, text, location, reflection, globalization,
resources, runtime, security, and diagnostics.
On top of core .NET Framework,
the Windows Phone application platform consists of two major frameworks:
Silverlight and XNA. You'll use Silverlight primarily for business
applications and simple 2D games. Silverlight uses the Extensible
Application Markup Language (XAML) that is declarative markup language
for creating compelling UI. The designers will have tremendous
flexibility in creating UI for Windows Phone using familiar tools like
Adobe Illustrator, Photoshop, and Microsoft Expression Design to create
vector-based UI that can be easily exported to XAML. XNA is primarily
used for creating games, and the framework comes with a game engine that
allows you to create loop-based games and also provides a 3D engine,
allowing you to create 3D games.
In the following sections, you
will learn more in detail about the main components of the Windows
Phone application platform: Silverlight, XNA, tools, and cloud services.
1. Silverlight for Windows Phone
The interesting thing
about Silverlight is that Silverlight is used in the web technology that
is browser plug-in that enables rich Internet application content just
like Flash technology. Silverlight provides you with a sandboxed
experience, and the limitation of Silverlight with respect to the
underlying operating system is clearly borderline. Within a Silverlight
application, you cannot access any native operating systems unless
through provided APIs, if any. This architecture of Silverlight makes it
very compelling security-wise to be used in Windows Phone, because
Windows Phone provides the same restriction of only providing APIs to
developers and limiting access to the native operating system.
Also Silverlight uses XAML,
which can be used to declare vector-based graphics and create
animations. Any designer familiar with vector-based applications, like
Adobe Illustrator and Microsoft Expression Design, can easily create
highly visual elements in vector and can be exported out to XAML. This
means the designers have full control over the layout, look and feel,
and graphical assets, making Silverlight an extremely powerful choice
for creating consumer-oriented applications. Also XAML provides a
powerful data binding feature to the controls making it ideal for
creating business oriented applications.
2. XNA for Windows Phone
Like Silverlight, XNA is not a
new technology. XNA is used in creating Xbox games, using managed code.
It is a natural choice for creating games since Windows Phone has Xbox
LIVE integration, allowing XNA-based Xbox games to be easily posted over
to Windows Phone. The only thing Xbox game developers have to worry
about is screen resolution, which can easily be adjusted and fixed.
XNA provides a rich framework
perfect for game developments, like a game loop engine, 2D and 3D
engines, and the ability to manage game assets like models, meshes,
sprites, textures, effects, terrains, and animations.
3. Tools
You can download the tools you need for developing Windows Phone applications from http://create.msdn.com/en-us/home/getting_started.
Also on this Getting Started page, you will find rich documentation and
tutorials. Also consider downloading the UI Design and Interaction
Guide to understand the Metro design guidelines that Microsoft
encourages you to use in developing applications.
3.1. Visual Studio
If you do not have a paid
version of Visual Studio 2010 on your development machine, then the
development tool that you have downloaded from Microsoft will install a
free version of Visual Studio 2010 Express for Windows Phone as show in Figure 1.
Visual Studio is absolutely necessary because it can be used to design,
debug, create projects, package and automatically generate package
manifests. It also includes a phone emulator on which to test the
results of your work.
3.2. Expression Blend
You will need Expression Blend if you want to develop compelling applications using Silverlight for Windows Phone as show in Figure 2.
Typically Expression Blend is used by designers, and many of the
Expression Blend functionalities are similar to Adobe Illustrator,
Photoshop, or Expression Design. Also from Expression Blend you can
import any Illustrator, and Photoshop files, and if you are using
Expression Design, you can export Expression Design file directly to an
XAML file.
Expression Blend also
provides a way to create animation sequences. Although you can achieve
in creating animation in Visual Studio using XAML, it would be very
difficult to write complex XAML code to represent complex graphics or
animation sequences. It is best to leave complex graphics and animations
to Expression Blend.
3.3. Windows Phone Emulator
The Windows Phone emulator as seen in Figure 3
is integrated to Visual Studio that simulates a real device. However,
there are things you cannot do in the emulator, like test the
accelerometer, GPS, compass, FM radio, SMS, e-mail, phone calling,
contact list, camera, and other features that require a physical device.
There is, however, a technique called Reactive Extensions, which you'll be able to use to simulate the data feed you can expect on
a real phone. For example, you'll learn how, using Reactive Extensions,
you can simulate the accelerometer and GPS readings so that you can
work with the emulator without the need of the device.
3.4. Documentation and Support
There are many ways you could get help while you are developing your application if you get stuck on a problem. You can visit http://create.msdn.com/en-us/home/getting_started,
and you will find the Windows Phone 7 Training Kit that might contain
how-tos on specific technology you are having problems with. You can go
to http://forums.silverlight.net/forums/63.aspx,
where you can ask about Silverlight for Windows Phone–related
questions, or if you have other related Windows Phone questions, you can
visit http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series. Also the Windows Phone development team puts out many useful blogs that you can follow at http://windowsteamblog.com/windows_phone/b/wpdev/. Of course, you also have Windows Phone documentation, found at MSDN http://msdn.microsoft.com/en-us/library/ff402535(VS.92).aspx.
4. Cloud Services
Working with a Windows
Phone application that requires saving the data to a database is a
tricky thing. The first big problem is that you do not know how popular
your application will be, and if it becomes popular, you might suddenly
find millions of users using your application and saving the data to its
database at a rate that would require an enterprise-level solution. Not
just database you would need to worry you also need to consider the web
service that can provide APIs to your application to save to the
database since Windows Phone applications cannot directly connect to the
database.
This is where the
Microsoft Azure cloud comes into your solution. Microsoft Azure provides
Windows Azure service for deploying services (WCF, Windows service) and
SQL Azure for the database that allows you to scale infinitely as your
demand grows larger.
There are also Bing Maps
services that you can use freely. Bing Maps is free only if you are
developing a Windows Phone application. Along with Bing Maps services,
Microsoft provides Bing Maps controls in Silverlight that you can use in
Windows Phone.
Push notification
services are hosted in the cloud as well, which allows you to push
messages to the phone, which is a very powerful messaging mechanism. Xbox LIVE services also reside in the cloud, which you can take
advantage of in your application. This topic will not be covered in this
book, however.
You learned a bit about
Windows Phone and the Windows Phone platform in the foregoing sections.
In the following sections, you will learn about the beginning to the end
of Windows Phone application development.
5. Metro Design
Microsoft is targeting Windows
Phone 7 toward busy professionals, and to provide compelling UI,
Microsoft came up with Metro design. Metro design derives from the
transportation industry typography and visual designs where busy
professionals constantly scan and go, and because of this, Metro design
puts heavy emphasis on simple and clean designs.
Metro design follow
five principles. First principle emphasize on clean, light, open, fast
to eliminate clutter, and typography, as consumers will be using the
phone to read e-mail, SMS, Facebook, and Twitter while on the go. The
second principle of Metro design puts the focus on content, where the
design premise must gear toward presenting the content. The third
principle focuses on seamless integration of hardware and software. The
fourth principle puts an emphasis on gestures, where the design enables a
world-class multitouch user experience. Lastly, the Metro design
concept focuses on an application that is soulful and alive, where
information that matters most to the user is presented in such a way
that it is easily accessible at the click of the touch. You can find out
more about Metro design by downloading the document provided by
Microsoft at http://go.microsoft.com/fwlink/?LinkID=183218.