Book Image

Windows Phone 7 Silverlight Cookbook

By : Jonathan Marbutt, Robb Schiefer
Book Image

Windows Phone 7 Silverlight Cookbook

By: Jonathan Marbutt, Robb Schiefer

Overview of this book

Silverlight has revolutionized development using Microsoft technologies. It is an excellent tool for mobile application development. The XAML-based markup and familiar C# code are the perfect combination for building apps efficiently and with minimum hassle.Packed full of recipes containing comprehensive instructions for the tasks required to build modern compelling smartphone apps using Silverlight.Starting with application design and architecture, you will quickly move on to more technical features and APIs you can implement to make your app stand out. You will use the Camera API to scan barcode, location services to pinpoint the user’s GPS coordinates and accelerometer to provide feedback based on movement of the phone. All of these features can be provided in a slick user interface through the power of Silverlight. Animations, behaviors and XAML provide all you need and more.
Table of Contents (18 chapters)
Windows Phone 7 Silverlight Cookbook
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a ViewModel


Now that we have our Model, it is time to do something with it. In the ViewModel, we will introduce several important concepts that are needed to begin implementing interactivity with our database and the UI. The key to the ViewModel is to think of it as the gatekeeper between your model, data, and your UI. It should be responsible for all interactions to get the data from your database or web service.

By creating a simple ViewModel, you will produce an easy to maintain layer of code for your application. It also gives you the ability to reuse the ViewModel with other views and keep the same functionality.

Getting ready

In our current BandTour project, we will create a folder called ViewModels. We will then create a class called BandViewModel.cs. This class will be responsible for creating the simple list of bands and concerts.

How to do it...

The first thing we want to add to our BandViewModel.cs is the initialization method that will create the data. For this example,...