Book Image

Windows Phone 7 Silverlight Cookbook

By : Robb Schiefer Jr., Jonathan Marbutt, Robb Schiefer
Book Image

Windows Phone 7 Silverlight Cookbook

By: Robb Schiefer Jr., 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
About the Authors
About the Reviewers

Using a WCF service in a Windows Phone application

Now that we have a WCF service to work with, we need to build an application that can bind to it from the Windows Phone. To do this, add a project to this solution by right-clicking the solution root and selecting Add New | Project. We add this project as a Windows Phone application called WCFClient.

Getting ready

Now that we have our project created, we will want to add a reference to the service by right-clicking the references folder and selecting Add Service Reference:

This will bring up the service reference tool, and we will hit the discover button to find the service that is in our other project:

Once you have seen this screen, simply change the NameSpace to MyServiceReference and then click OK.

How to do it...

Now to build a ViewModel that can get data from this data service:

  1. 1. Add a new class file to our project called MyViewModel.cs. This will provide the code in the client side to call the server.

  2. 2. Set up a reference to the service...