There are a ton of new mobile platforms out there — iPhone, Android, Symbian
and a few more. The first two have really taken off due to the availability of
lots of apps in their respective App Stores. Microsoft's own mobile phone OS —
Windows Mobile — has been stagnating for a while now, even though it had a great
development platform. However, Microsoft has not really given up the race. Its
upcoming Windows Phone 7 platform and the 'Metro' UI based on the Zune HD
interface has been getting mostly rave reviews from whoever has played with the
devices and software till now. Not only does it bring a completely new paradigm
to the interface over the much-used icon based format, it also doubles up as a
great development platform that can be used quite easily.
This article series will delve into the world of Windows Phone 7 (WP7, in
short) development. We'll try to develop a real-world application over the
coming months in this article that will explore all the different new features
that are available in the platform. This part of the series starts off with an
introduction to the platform itself and the setting up of the development
environment.
Creating your first WP7 project in VS2010. |
Windows Phone 7 Development Platform
The Windows Phone 7 platform allows developers to create applications in two
different ways:
Using Silverlight: This is the primary way that apps will be developed
for WP7 and consists of the application written in Silverlight — Microsoft's
XAML based application development platform. The Silverlight available in WP7 is
a special version built upon the Silverlight 3 with some phone specific
additions made available. The developer will also get access to a large number
of phone SDK calls that will let him perform some common tasks quite easily.
Using XNA: This is meant primarily for developers who are creating
games for the WP7 platform. Not only will it allow more direct access to the
graphics and sound hardware in the phone, it also has the ability to access the
Games Hub (more about this a little later) and be able to synchronize the same
game across the phone, PC and Xbox 360. In this series we will be looking only
at the Silverlight apps development for the phone.
The initial look in of a WP7 project. |
Development Tools
Developing for WP7 is quite easy. The tools are currently in Beta state and
freely available. The good thing is that even when the final release is done, it
will also be made available completely for free. So you can start coding in the
beta release secure in the knowledge that when the RTM hits, you can simply
upgrade the install bits and it will start working. You can get the tools from
http:// developer.windowsphone.com/. So what all does this have? Here's a list
of what you get when you install the tools:
Visual Studio 2010 Express for Windows Phone: A special version of
VS2010 for WP7 development
The WP7 emulator launching your first app. |
Expression Blend for Windows Phone: Another special version of Blend
for WP7 UI designing
Windows Phone 7 Emulator: This is a full working image of an unlocked
WP7 device that you can use to test and debug your apps till you get a real
device
XNA Studio for Windows Phone: This is the XNA Game Development studio
for WP7
Developer Registration Utility: Used to unlock your device for
development
XAP Deployment Tool: For transferring XAP files directly to your phone
So, let's get started with a simple application first for this series. We'll
starting looking into the different 'features' of the WP7 platform and how to
develop for it in later parts. So go ahead and install the tools first.
Your First WP7 App
To start off, open up Visual Studio 2010 Express for Windows Phone — or if
you already had a version of VS2010 installed, fire it up and go to the New
Project window. Here select Visual C# | Silverlight for Windows Phone | Windows
Phone Application. Give it a name like WP7HelloWorld and create it.
When the project is loaded, you will by default see the Windows Phone 7
designer on the left pane and the Silverlight XAML on the right. XAML and
Silverlight is out of scope of this article but PCQuest has carried detailed
articles on developing Silverlight applications earlier. You can also find a
number of Silverlight tutorials on the Web.
You first app for WP7 - a tiny Twitter client in 2 min. | Using the OSK to interact with the app. |
For this sample, let's first do something very simple. Select the TextBlock
that says 'MY APPLICATION'. You can change this over in the property window on
the right to say 'MY FIRST WP7 APP'. Now select the 'page name' text block and
find the TextBlock element in the XAML pane whose name is 'PageTitle'. Change
the Text value to 'first page'. You will immediately see the changes reflect in
the designer window. Now open the toolbox and drop in a TextBox, a button and a
WebBrowser control. Change the first two controls' texts to ' and 'View'.
Double click the button to enter its click event handler and enter the following
code.
private void button1_Click(object sender,
RoutedEventArgs e)
{
webBrowser1.Navigate(new
Uri(string.Format("http://twitter.com/{0}", textBox1.Text)));
}
Save both the files and press F5 to compile and debug the application. By
default, the app will be deployed to the WP7 Emulator. So wait while the
emulator boots up and the Silverlight .XAP file is deployed to the emulator.
Once ready , the application is launched automatically. You can now start using
it. For entering text into the textbox you can either use the on screen keyboard
that automatically appears or press “Pause/Break” on your keyboard and then
simply type as you would normally. Press the 'View' button to load the Twitter
account into the Web control. In a single line of code and 2 minutes of time,
you've actually built a small Twitter client for WP7! Also remember that since
this is running in 'Debug' mode in VS2010, you can use breakpoints, watches and
all the other development tools built into VS to work with your application. You
can also open the app in Blend to make its interface much more dynamic. But
we'll take a look at all of this in the coming months.
For now, WP7 is still in the hands of only a few. But with the WP7 developer
tools, you can get a taste of the platform as well as start developing
applications for it right now so that a completely new market is available to
your app as soon as the devices arrive by the end of this year.
Related Articles:
Win Phone 7: Data Binding & Storing Persistent Data Writing code