By Rob Howard, Dan Maycock and Greg Martin
Developers of iPhone applications possess the fundamentals and key understanding for building applications for small form factor devices. When creating a mobile application for Windows Phone 7 however, the means for developing the application changes. This platform is a considerable departure from Microsoft’s previous mobile operating systems so this article will help describe what you’ll encounter porting an existing iPhone application to Windows Phone 7.
Whether it’s the difference between Objective-C vs .Net, or the iOS SDK vs the Windows Phone 7 SDK, a number of differences exist which will be explained throughout this article. We’re going to walk through our own process of porting an internal iPhone application, Slalom Cards, into a comparable version for Windows Phone 7. The goal of this article is not only provide you with the knowledge necessary to port an existing application to Windows Phone 7, but to also better understand the platform a whole for new development.
Windows Phone 7 applications are built and tested utilizing Visual Studio. All the tools to get started can be downloaded at http://developer.windowsphone.com
as well as guides and tips to get up to speed with the Windows Phone 7 development environment.
As a note, the development environment DOES require the Windows Operating System (Windows Vista or Windows 7). Also, the emulator does not seem to run well in a VM (like Parallels or Fusion), so it will be necessary to boot directly into Windows if you want to debug.
You will need to download the developer tools on this website. They are a free download and it includes the following:
a. Visual Studio 2010 Express for Windows Phone Beta
b. Windows Phone Emulator Beta
c. Silverlight for Windows Phone Beta
d. Microsoft Expression Blend for Windows Phone Beta
e. XNA Game Studio 4.0 Beta
f. The UI Design and Interaction Guide for Windows Phone 7 can be found linked on the Windows Phone developer site at http://go.microsoft.com/?linkid=9713252
Construction of the Application: The Easy Things
Migration of the Data Model
Since the languages support similar features (both object-oriented c-like languages that support things like properties and methods) porting most of the model items will be pretty straightforward with a one to one mapping of fields and methods. Note: C# is currently the only supported programming language for Development for Windows Phone 7.
Windows Phone 7 allows the developer to use Windows Communication Foundation (WCF), HttpWebRequest, and WebClient.
WCF works very well with SOAP web services. It is very simple to set up a connection that would generate all of the networking code and object classes that it uses.
For RESTful services, WCF is also very useful but we will have to do a little bit more work deserializing the data into objects. There are many ways to do this; .Net provides some simple DataContract Serializers and Deserializers that work well with XML and JSON.
User Interface Elements
Windows Phone 7 provides a few ways to author and edit the user interface.
One can use the preview pane within the IDE for layout and addition to controls. This is very similar to the Interface Builder application that is part of the iOS SDK. Users of Interface Builder will become easily familiar with this method of UI authoring and manipulation.
Also in the IDE is a view of the XAML that can be very useful for a developer to see and modify. This code behind the presentation is an easy way to see the output of the UI layout engine, and gives a chance to add function handlers, custom properties on classes, and to fine tune your code.
There is also a version of Expression Studio for the Windows Phone. Like Expression for web based Silverlight applications or WPF implementations, this provides a more designer focused interface which allows you to creating templates, behaviors, animations, and many other custom UI.
Like most mobile phone operating systems, Windows Phone 7 provides a stack based navigation system along with application buttons that can be used, like in the iPhone, as a tabbed based navigation system. The API provides NavigatedTo and NavigatedFrom methods that are similar to the ViewDidAppear, and ViewDidDisappear methods that the iPhone supports.