Monthly Archives: February 2012

What is this ViewModel?

Now I will explain a little bit about MVVM. MVVM is an architectural pattern. It stands for Model View ViewModel. Wikipedia has a decent explanation about it (http://en.wikipedia.org/wiki/Model_View_ViewModel)

The way I view MVVM is like this. It separates the Data(Model), from the presentation(View) and the ViewModel handles updating the Data when something changes on the View. It is useful, but I also feel if you are doing simple little apps you don’t need to use MVVM as it just takes up to much time and resources. But it is also a good thing to know and understand.

If you created have checked out my previous posts and followed along, you should have noticed folders in the project that separated the Model, View and ViewModel out. If you wanted you could also check out the MVVM example from here (http://msdn.microsoft.com/en-us/library/ff431744(v=VS.92).aspx#BKMK_Common) also check out this short video if you want. http://msdn.microsoft.com/en-us/Video/gg241309

So if you start to notice in those examples, The view uses the ViewModel to get and set data to display and change, and the ViewModel updates the Model when it is saved. They do this as seperation of data and presentation. Separation helps with cleaner looking code and also has the ability to have a designer working on the View while a developer works on the data and that. But like I mentioned before if you are building a simple app, doing it in MVVM can cause a lot of overhead that isn’t really needed, but I still encourage you to try building an app with the MVVM pattern to get use to it.

I am still learning MVVM and have only had so much experience with it, but if you plan on really getting into WP7 application development, I suggest you read up on MVVM and try to build an app using the MVVM pattern. Any suggestions for me about MVVM or any questions please let me know.

Lets go into the solution!

Now that you have created your sample pivot application from the previous blog post. (http://www.underbridgecity.net/blog/2012/02/a-new-project/) 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”.

Read more »

A New Project…

Ok now it is time to get started. Open up Visual Studio. I am using Visual Studio 2010 Professional version, if you have Visual Studio for Windows Phone Express that is perfect for building windows phone 7 apps. I will now refer to Visual Studio as VS.

Once you open up VS you should see a welcome screen and in the upper left see a link for a New Project… Click that.

Then you should see a screen where you can select what type of project you would like to make. Here I selected a Windows Phone Pivot Application. Give it a name and click ok. The name is the name of your project, this will create a folder in your projects folder for VS. This doesn’t have to be the name of your app.

Read more »

Time for a plan.

Well my WP7 game was just published to the marketplace. If you want to check it out, the name of it is LeftOrRight. Or you can click here to check out a site I made with this awesome Wp7 app template page. http://www.underbridgecity.net/leftorright/ If you like the page template, and want it for your own WP7 app you can get it here WP7 App Site and it is by Nick Harewood

Ok now to get started on creating your own app. First this first, you need to come up with an idea. It doens’t have to be this grand idea that will solve all the world issues, start small and simple. I thought of my idea as I was waiting to play a hockey game. It started with me thinking, “I want to create an app that I can get into the marketplace by the end of the week.” I didn’t get it in by the end of that week, but I wanted something I wouldn’t spend a long time on. So I came up with a simple game of guessing left or right. Sounds simple right, and it kinda was.

Before I even hit File > New Project, the first thing I did was pull out some paper and write down my thoughts. I wrote down my objective, “A game of guessing Left or Right that uses the WP7 Metro interface.” Next I started planning out how I would do that. I decided to keep it all in a silverlight project and not XNA to make it easier and also there would be no graphics in it.

Then came the parts where I wrote down my plan on how I was going to code it. It went like this,

1. Design the UI.

1a. Create Pivot page with 3 pivots. b. add buttons on each page. c. have a score always display and not change with the pivote pages.

2. Start the coding

2a. hook up button events. 2b. Create the functions to get the anwser and check the anwser. 2c. Hook up UI events to code funstions

3. Test it!

3a. Test

 

That Was my original plan, and Lets just say there was a lot more added in after I started work on it and there was more after test it… like recode this, make this look nicer, test it again. But At least I had a starting point. So if you want to start your own app, I suggest taking just a few min to plan out what you are going to do. I don’t think you need a fully designed idea before you start programming a starter app, it could help but I like the approch of having a general idea at first and then diving right now.

So get cracking, think of an idea, make a plan. If you need help or just want to play araound with some sample projects check out. http://msdn.microsoft.com/en-us/library/ff431744.aspx

Happy Coding!

A good resource for WP7

I just submitted my app to the marketplace, and now I just have to wait for it to get approved. As I wait I will let you all know about a great resource I used to help me complete the app.

http://jeffblankenburg.com/31daysofmango/

That is the 31 days of mango by Jeff Blankenburg. He is a totally awesome developer who was one the the big motivators to get me to finish and app, and also start blogging. I suggest you check that out, also you can totally buy the 31 days of mango in ebook form. I suggest you do that.

Lets get started.

So lets get started on a little project. I am going to start writting about how I came up with an idea for a Windows Phone 7 app, started a little simple design, programmed it, tested it, and then released it to the marketplace. My app is currently going though the approval process so I hope to have it published soon.

Before you even start, you need to have the right tools. The first and most imporatant tool you will need is the Windows Phone 7 SDK that comes with Visual Studio for Windows Phone which you can download at the apphub (http://create.msdn.com). Download and install that then the next thing I suggest you download is the Silverlight for Windows Phone 7 toolkit. (http://silverlight.codeplex.com/)

Download and install those, While doing that some suggested reading is on the apphub like http://create.msdn.com/en-US/education/basics/developer_resources and you can view some sample code at http://msdn.microsoft.com/en-us/library/ff431744.aspx

If you want to get started developing Windows Phone 7 app, or even just getting started into some C# programming, download the WP7 SDK and start reading.

Hello World!

I think this subject line is very fitting for this first entry of my blog. When every I hear Hello World! I think of the very first program I created in C++. That was quite a few years ago in highschool, but that is what started me in the wonderful world of being a programmer.

This blog will be mostly about my programming experiences, about how I solved problems, how I went about programming something, and other wonderful random stuff mostly dealing with programming.

I will soon be posting a series about how I went about creating a small simple little Windows Phone 7 game, and how I am going to continue adding to it to make it better. I plan on making it about the whole process (planning, designing, coding, testing, submitting, and updating)

Thank you for reading and I hope my writting will help you in some way.

-Andrew