Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Using Solution Explorer in Visual Studio for Windows Phone App Creation

DZone's Guide to

Using Solution Explorer in Visual Studio for Windows Phone App Creation

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

Now that you have created your sample pivot application from the previous blog post, we will talk a little about what is going on. To the right inside Visual Studio you should see the solution explorer.
 

I will explain what the files in the solution explore are and what they are used for.

A solution is a… solution! A solution is a a collection of projects that are used to create the whole program. We only have one project in our solution and that is all we really need right now.

A Project holds a set of files and in our case this project is the silverlight for windows phone project. The project file is named “SamplePivotApp” in the image above. If we wanted we could create another project and have our windows phone project reference it, but I will get into that into a future post.

Now onto the folders in our project, you will see a Properties folder which contains files that is used for meta data for our app. If you wanted open them up and look though them, but don’t change anything in them right now. For our Windows Phone 7 app the most important file is the WMAppManifest.xml. This file contains information on what our app can do, if it belongs to a special app hub on the phone (like the games hub, pictures hub or music hub.) If you are not familiar with the term hub in windows phone it is what Microsoft referes to as its sections on the phone. If you have access to a windows phone, you should see the different tiles and if you open one of the hubs I mentioned above you might see some apps in there. That is becasue those apps relate to that hub, so if you create a game you will want to put it in this game hub, and you can do that by changing the Genre attribute on the app tag to “apps.games”.

The next folder is the references, here is where you can add reference to libraries or other projects. an example would be if you downloaded the silverlight toolkit for windows phone 7 (http://silverlight.codeplex.com/) and wanted to use it. You would have to add a reference to it by right clicking on the reference folder clikc on “Add reference” and pick the Microsoft.Phone.Controls.Toolkit component name under the .NET tab. Once you add that reference you can use it in your project.

Now The sample Data folder just contains a .xaml file that hold sample data. This sample data is used only to help you know what a page looks like as you create it. If you open the MainPage.xaml file you should see an exmaple of what your windows phone app will look like, that is loading the file in the sample data folder. If you look at the xaml code in the MainPage.xaml you should see a line
d:DataContext="{d:DesignData SampleData/MainViewModelSampleData.xaml}"
That is what is loading the data into the preview. I will explain more about this in a future post.

Next is the ViewModels folder. Here is where we the “ViewModel” files are located. What is a view model you ask? Well I will also explain that in an upcomming post, but a quick explanition is it is part of a design pattern commenly used in Windows Phone 7 silverlight apps, it is also used in Silverlight apps and WPF. The name of that design pattern is MVVM which stands for “Model View ViewModel.” It is used to seperate the data objects (model) from the user interface (view). The viewmodel is a model of the view, but it is used to connect the data that is displayed in the view to the data objects created.

Next we see the App.xaml and App.xaml.cs files. The important one here is the .cs file, this file is used to handle application events from starting up and closing and handling unhandeled exceptions. Open it up and look, and you will see a bunch of methods with a short explantion above them. Read though these to try and understand what is going on.

Then the only files left are image files which are used as the image of the app on the windows phone screen and the splash screen which is used as the application loads. And then the MainPage file which is the main page of our application.

I hope you found this a nicely detailed post about what you are seeing in the solution explorer. If you have any questions, please ask. Thank you for reading and check back soon for my next post.

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:

Published at DZone with permission of Andrew Conlisk, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}