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

Custom behavior


One of the limitations with behaviors is that most of the time they are not really complex, which is great but sometimes you need to create a very reusable set of functionality that is an action. We can do this by creating a custom behavior. In our case, this example will be just to show a popup with a string that is passed in.

Getting ready

To get started, add an item to the project we've been working on and name it ShowPopupBehavior, as shown in the following screenshot:

How to do it...

As we have seen in the previous examples it is easy to implement the built in behaviors, but what if you want more functionality, this is how we do it.

  1. 1. From the Projects tab, we will want to open the file in Visual Studio by right-clicking the file and selecting Edit in Visual Studio.

    Luckily when creating a behavior in Blend like this, before going into Visual Studio, it creates a nice template for you to go by as follows:

    using System;
    using System.Collections.Generic;
    using System.Text;...