Over a million developers have joined DZone.

Creating a WP7 project for the PinCodeKeeper app

· Mobile Zone

Visually compose APIs with easy-to-use tooling. Learn how IBM API Connect provides near-universal access to data and services both on-premises and in the cloud, brought to you in partnership with IBM.

In this article I will go through the steps for creating and structuring a Windows Phone 7 app in Visual Studio 2010. In an earlier article I did some sketching and analysing for the PinCodeKeeper app and I will now start developing this application.

I will not go through the steps for installing Windows Phone Developer tools, if you have not all ready installed these tools have a look at this article: Installing Windows Phone Developer Tools. I am using Visual Studio 2010 Ultimate with the latest Windows Phone Developer Tools installed.

Create a Windows Phone project

In Visual Studio 2010 select “New project” –> “Silverlight for Windows Phone” –> “Windows Phone Application”. Then give the project a name and click “OK”, I named my project “PinCodeKeeper”.

Structuring the project

As a result of the sketching and analyses I did earlier for the PinCodeKeeper I know that I will be using the Model-View-Presenter (MVP) pattern and I know what views (screens) I will be using. Therefore I start by adding some folders to my project: “Model”, “View” and “Presenter”.

I know that I will have 4 views so I add these right away. In the Solution Explorer right click the “View” folder you just created and select “Add” –> “New Item” –> “Windows Phone Portrait Page” and name it “PinCodeListView.xaml”. I do the same for the three remaining views and add “PinCodeView.xaml”, “NewPinCodeView.xaml” and “AboutView.xaml”. I now have my views and I delete the auto generated “MainPage.xaml” file. Since I deleted the “MainPage.xaml” I need to change the start screen, you do that in the “WMAppManifest.xml” file located in the “Properties” folder. Change the “NavigationPage” value in the “DefaultTask” element to “View/PinCodeListView.xaml”.

Then I know that each view will have it’s corresponding presenter. In the Solution Explorer right click the “Presenter” folder you just created and select “Add” –> “Class” and name it “PinCodeListPresenter.cs”. Do the same for the three others and name them “PinCodePresenter.cs”, “NewPinCodePresenter.cs” and “AboutPresenter.cs”.

For the model I know that I need a class to represent a pin code and I need a class to represent a list of pin codes. Right click the “Model” folder and add “PinCode.cs” and “PinCodeList.cs”.

We now have a skeleton for our application ready, as you might have noticed I don’t use the normally used Interfaces for MVP-pattern in this application.

Your project should now look something like this in the Solution Explorer:


Project structure for PinCodeKeeper

The next step now will be to write the code for the screen displaying list of pin codes.


The Mobile Zone is brought to you in partnership with Strongloop and IBM.  Visually compose APIs with easy-to-use tooling. Learn how IBM API Connect provides near-universal access to data and services both on-premises and in the cloud.

Topics:

Published at DZone with permission of Per Ola Sæther, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}