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

Setting up a Command (MVVM) in Windows Phone 8 Video Tutorial

DZone's Guide to

Setting up a Command (MVVM) in Windows Phone 8 Video Tutorial

·
Free Resource

Introduction

I hear this question a lot.. Should I use code-behind or MVVM in my application? What are the pros/cons of each and can you show me a simple example of how a Command works?

  • With Code-Behind – Your page is tightly coupled with your UI, testing is harder, it gets really messy with larger apps. On the other hand, smaller apps with just a couple of screens, it may make sense.
  • With MVVM  – You can make drastic changes to the UI, with no impact to the data and business logic (true separation of concerns), easier to test, not necessary IMHO for smaller apps with just a couple of screens.

I could go a lot deeper with this topic but won't at this time. I’d really encourage you to use your Google-Fu to do more in-depth research on this.

Others may agree or disagree with me regarding smaller apps, but hey, that is my opinion. :) I’m also not a purist – meaning that I don’t find a problem with having some code-behind in my MVVM apps. I guess that counts as another strike against me! Dang it!

A Simple Example of Setting Up a Command

Anyways, I decided to try out CodeProject.TV to launch a simple example called, “Setting up a Command (MVVM) in Windows Phone 8”.  In this video, I show you how Commands work for projects that use MVVM (Model View View-Model). I will take a simple button and add a Command to it to display a MessageBox. This same code would work with other XAML platforms, such as WPF, SL, Windows Phone 7.x and Windows Store Apps (except the XMLNS declaration).

Let me know if you need any help and please vote up the video!

Topics:

Published at DZone with permission of Michael Crump. See the original article here.

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

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

X

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

{{ parent.tldr }}

{{ parent.urlSource.name }}