App Hub

article details

Jesse Liberty's "Windows Phone From Scratch" Tutorials

Submitted
2/23/2011
Article
Jesse Liberty is a senior community program manager in Microsoft Developer Guidance, focused on Windows Phone 7. His blog, http://JesseLiberty.com, is a required resource for Silverlight and Windows Phone developers.

Following are links to many "Windows Phone From Scratch" mini-tutorials that Liberty created for his blog. The series assumes that developers want to learn to program for the Windows Phone, but have no experience with Silverlight, C#, or .NET.

Link Subject
Getting Started This is the first in the Windows From Scratch mini-tutorial series. This series assumes you have no experience with Silverlight nor with C#, nor .NET in general, but would like to learn to program the Windows Phone.
Silverlight vs XNA You can write for Windows Phone using either Silverlight or XNA. Here are some general guidelines to help with understanding the strengths of each of the two platforms (from the Windows Phone 7 Developer Portal).
First Project Open Expression Blend (which you downloaded in mini-tutorial #1) and select New Project. In the New Project dialog box, select Windows Phone in the left pane, Windows Phone Databound Application in the upper right, and name the application WPFS3.
XAML In the previous mini-tutorial in this series you created a form in which you placed a prompt and text box for the first name using Expression Blend and drag and drop. It was probably not obvious that as you created columns and rows and as you dragged controls onto the form, Blend was creating XAML code for you that represented your design.
Data Binding Databinding is a somewhat advanced topic, typically covered in the second or even the final third of most Silverlight books. We’re going to tackle it in the next couple mini-tutorials because
  • It isn’t difficult to understand
  • It isn’t difficult to implement
  • It is critical both to most applications and to the principal design pattern used with Windows Phone: MVVM
Data Binding Part II Whoa! Insurrection on this series! Fair enough, it is based on the quite legitimate complaint that the mini-tutorials were too mini and not enough tutorial. To make up for this deficiency, this mini-tutorial will cover steps 2 and 3 described in the previous mini-tutorial: creating the form and basic data binding.
Data Binding Part III: Element Binding This mini-tutorial extends the work done in number 6, adding a slider and a text block bound to the value of the slider, through element binding – that is, the binding of one element’s value (in this case the TextBlock) to a value in a second element (in this case the slider).
Reactive Programming: Async Call Backs One of the tried and true patterns in .NET programming is to call an Asynchronous service (e.g., BeginGetResponse) and to then provide a callback to a second method for when the call completes. This can get very complex very quickly if you have chained calls (call this, then when you finish, call that).
Let’s take a look at how you can simplify such a call with Rx by examining making a HTTPWebRequest.
Styles Let’s take a look at how styles can unify the look and feel of a Windows Phone application. This and the next few Windows Phone From Scratch (WPFS) postings will use the same form, so we’ll begin by creating a new Windows Phone Application in Expression Blend, and we’ll name it WPFS8.
Visual State When transitioning from one state (e.g., button up) to another (e.g., button pressed) the user expects and requires visual feedback. Often this is provided with animation: the button appears to descend. Creating this animation is greatly simplified by the Visual State Manager in Silverlight, and thus in Windows Phone 7.
Visual State Part II This mini-tutorial will build on the work done yesterday, and will demonstrate how to return to the default visual state for a given state group.
Suppose that instead of having a red dot that indicates that there is data to update and a green dot that indicates that the data has been saved, your specification calls for a red dot to appear when data needs to be updated and to disappear when that data is saved.
Behaviors Behaviors are, in my experience, under-appreciated by many Silverlight and Windows Phone programmers; possibly because they are most easily used from Expression Blend, which itself is greatly under-appreciated.
A behavior is an encapsulation of logic within Xaml – it is essentially, declarative logic. As such it has many advantages over writing the same logic in C#, notably that of re-use.
MVVM Custom Behaviors Part I To fully understand how behaviors work, you need to create a couple custom Behaviors of your own. In this tutorial we’ll build a custom behavior and in the next we’ll look at a specialized form of custom behavior called a TriggerAction.
MVVM Custom Behaviors Part II: Action Trigger In the previous mini-tutorial you saw how to create a custom Behavior, and in that custom behavior you captured the on click action event of the button. This pattern is so common that there is a special type of behavior, an ActionTrigger to simplify coding a custom behavior the responds to an event.
MVVM Light Part II: Behaviors This is the second part of the MVVM Light Toollkit Soup To Nuts (part 1 is here) within the Windows Phone From Scratch Mini-tutorial series. Today we look at an introduction to behaviors as a tool for migrating event handling from code-behind to the View-Model.
MVVM Light Part III: Messaging This is the third part of the MVVM Light Toollkit Soup To Nuts (part 1 is here) within the Windows Phone From Scratch Mini-tutorial series. Today we look at an introduction to messaging as a tool for communicating, e.g., from the view-model to the view.
MVVM Light Toolkit: Part IV Let’s back up a bit and examine the day to day use of a View Model, and binding to the view model. In this mini-tutorial I’ll show the basics of binding a collection that sits in a View Model to a list box in the view. In the next, I’ll show how to capture the selection and, in the view model, determine what the details page should show.
MVVM Light: Behaviors: Passing Paramaters In the previous posting in this series, we created a list of customers and we bound them to a list box. We did this not in the code-behind but in the View-Model. This forces the question of how we respond when a user makes a selection in the list box, if the logic for handling the selection is to be not in the view (the code-behind) but in the view-model.
Animation Without a Lick of Code Animation, used with restraint, can greatly enhance the user’s experience of the phone; clarifying transitions and creating useful illusions. One, discussed here previously, is the illusion of “flipping” part of the page over, perhaps to reveal a help file.
Animation Animation in Silverlight is declared in Storyboards and triggered by a user’s action, by a background action or process or, most commonly, by a change in state. Thus an animation might be triggered by pressing a button, but more often the animation will ease the user’s perception of the transition from one state such as the mouse-over, to another, such as mouse press.
Launchers and Choosers: Address Book To provide your Windows Phone application access to the operating system (and with it, to the native applications such as SMS, the Contact List, the Camera, and, oh yes, making a call) Windows Phone 7 has a set of predefined Tasks.
Launchers and Choosers Part II: SMS In yesterday’s posting we created an application that used a chooser to allow you to pick a name from the contacts list and to obtain the related phone number.
Today we’ll use that information to launch the SMS service to send a message to the selected user.
Launchers and Choosers: Camera On January 24 we created an application that launched the contact list and returned the phone number of the selected contact. In that posting I reviewed, briefly, the difference between Launchers and Choosers. This posting builds on that work.
Today we will use the Chooser for the Camera, which will bring up the camera and then return the location of the image taken.
Linq and Fluent Programming I interviewed Bill Wagner for yet another Podcast while we were both at CodeMash (look for his interview to be published next week). In addition to being one of the nicest guys I know, he is also one of the smartest.
During the conversation he illustrated the ideas behind Linq and Fluent programming with a verbal example. With his permission, I’ve picked up that example and present it here as a crisp crystallization of these key programming concepts.
Reactive Programming I’m increasingly convinced that Reactive Programming is going to be critical for Silverlight and Windows Phone developers. Reactive Programming is not new, and the Rx toolkit has been out for a while, but this is not a heavily covered topic, and the more I look the more I think it should must be.
Reactive Programming: Async My first posting about Reactive Programming for Windows Phone generated some terrific comments… many of which asked (and others answered) “what is the benefit of this?”
In this second posting on the topic I’ll tackle a bit of asynchronous programming that may help to illustrate how the implementation of the observer pattern by the Reactive Programming framework can greatly simplify Windows Phone programming.
Reactive Programming: Observable Sequences In yesterdays’ posting on Asynchronous programming with Reactive Extensions I created a browser application that reacted to user input into a TextBox.
Life Cycle One of the key dilemmas facing Windows Phone 7 programmers is how we maintain an extremely responsive experience for the user, provide some sort of multi-tasking and preserve battery life, all at the same time? The solution offered by Windows Phone 7 is to tombstone applications when they are inactive. This tutorial will explore tombstoning, multi-tasking and the entire application life cycle in detail.
Life Cycle: Page State Management In previous postings, I’ve discussed the Life Cycle of a Windows Phone application and in that context noted the requirement to maintain the page’s state when the user navigates away (so that state can be restored when the user returns).
There are a few practical elements to state management, so let’s devote a few of these mini-tutorials to the exact mechanisms involved.
Isolated Storage An essential ingredient in storing the state of your application, especially when your application may be tombstoned or, even more extreme, closed, is the ability to create persistent storage – that is to write to the disk so that you can retrieve your data when the application resumes or is restarted.
Application Bar The application bar sits at the bottom of your Windows Phone application and provides a set of hopefully not-too-cryptic icons, along with an ellipses (…) that pops open the menu and the text associated with each icon.
Creating these icons by hand requires a bit more artistic skill than I have, so I’ve shied away for a bit, but it turns out that Blend makes creating an Application Bar a relatively trivial exercise.
MVVM Light Tookkit: Part I While I’m not a zealot on the topic, I do believe that MVVM offers one of the best patterns for Windows Phone development and so, moving forward, the Windows Phone From Scratch series will incorporate MVVM in general, and the MVVM Light Toolkit in particular.
Navigation To navigate from one page to another, you can take advantage of the static Navigate method on the page’s read-only NavigationService property. This passes your request to the NavigationService Singleton for your application, and greatly simplifies the navigation syntax.
Navigation: Part II In the previous WPFS we covered the basics of Navigation and the in the one before that we covered the fundamentals of animation. Let’s combine these two ideas to create a better navigation experience.
Navigation 101: Cancelling Navigation Let’s go back and look at the fundamentals of Navigation and how you can exert greater control as you navigate from page to page in your Windows Phone application.
Simple navigation, say from one page to the next, can be accomplished by calling on the NavigationService’s Navigate method, passing in the URI of the page you wish to navigate to.
LINQ: Getting Started If you are serious about Windows Phone programming then it is imperative to become at least familiar with LINQ. This is given additional impetus by the emerging importance of Reactive Programming, a full understanding of which requires at least a working understanding of LINQ.
LINQ with Objects In my earlier post, we took a first look at a Linq query against a collection of integers. In this posting, we’ll look at creating a Linq query against a collection of objects.
We first need an object; we’ll create a new class: Customer. (To do this, right click on the project and select Add->Class. Name the class customer.cs).
LINQ to XML Earlier, we took a look at two variants on Linq statements, one against a collection of integers, and then another against a collection of user-defined objects (Customers).
Now, we’ll read an XML file and select from that with Linq.
Lambda Expressions Yesterday I wrote a few posts on LINQ but carefully avoided using Lambda expressions. Now it is time to look at this feature that sounds fierce but is really fairly straight-forward.
Lambda expressions are just a short-hand notation for declaring delegates.
Database Programming with Sterling When you wish to persist state across usages of your application, Isolated Storage allows you to write to the disk and stash away key-value pairs. For state, this is usually sufficient, but if what you wish to persist is data, especially relational data, then Isolated Storage is a bit limiting.
Sterling DB on Top of Isolated Storage: Part II In yesterday’s posting we looked at the Sterling Database. and how to set up and initialize tables, store an retrieve data. Today we’ll build on that to set up the database in App.xaml so that we can handle tombstoning.
The key change to yesterday’s program is that rather than initializing the database in the main page, we’ll do so in App.xaml. To see this at work, create a new Windows Phone application.
From Android to Windows Phone This is the first in a series of mini-tutorials and related content on moving applications from Android to Windows Phone.
To get us started, let’s take a look at a simple Android application that takes an amount and computes the total with an 18% tip. We’ll then rebuild it in Windows Phone.

 

find education content
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG