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:
The next step now will be to write the code for the screen displaying list of pin codes.