Author: Charles Petzold
Publisher: Microsoft Press, 2011
Aimed at: C# programmers
Pros: An excellent presentation with helpful examples
Cons: Late introduction of Pivot and Panorama controls
Reviewed by:Mike James
This is a book about programming Windows Phone 7 mainly but not exclusively using Silverlight.
The first thing you need to know is that it is available as a free eBook from Microsoft in an edition which covers both Silverlight and XNA. I started to read this book as a PDF on a Kindle and while it was OK it I was relieved to switch to the printed edition as soon as it was available.
This book is by the legendary Charles Petzold who did so much to enable us to get started with creating applications for the early Windows. The task of creating Windows Phone apps is by no means as difficult as working with 16-bit Windows, but it's nice to know that the author has a pedigree.
Part 1 of the book is, reasonably and obviously enough, called "The Basics". This describes the design of the phone and how to get started with the development environment. Soon you have your first Silverlight and your first XNA minimal "hello world" programs running. The good thing about Part 1 is that Silverlight and XNA development go hand in hand. Every time you do something in Silverlight the same problem is tackled in XNA. This dual treatment is a unique feature of this book and I think it helps. While many programmers will specialise in either Silverlight or XNA, knowing how the two fit together is illuminating and potentially useful - making them work together might be just what you need.
This said, it is important to realise that if you have programmed Silverlight, WPF or XNA you will find many of the topics revision. However, the author usually manages to say something down to earth that brings even something you know into clear focus. Chapter 3 on handling touch events is particularly interesting. Chapter 4 looks at using bitmaps, Chapter 5 deals with sensors and Chapter 6 clarifies application architecture - tombstoning in particular. None of this is especially advanced but it is core and it is well explained. At the end of part I you should have a good grounding in writing programs for the WP7 and have a reasonable grasp of the differences between the two approaches to creating apps and what each is particularly good at.
Part II, starting at page 143, focuses on Silverlight development alone and it is a shame to leave XNA behind, but the good news is that there is a companion volume that deals with XNA. Much of the discussion in this part is about the way XAML and code interact. Chapter 7 is a good introduction to XAML and I recommend that you read it even if you have been using XAML for a while just to fill in anything missing gaps in your knowledge. Chapter 8 explains some basics of using elements - shapes, simple animation, playing movies, working with bitmaps and so on. Chapter 9 focuses on layout with a look at the standard Silverlight layout panels - stack, grid and canvas. At last someone is prepared to say:
"The Grid should be your default choice of panel..."
Good advice and it also holds for Silverlight and WPF development.
Chapter 10 moves on to consider some Phone specific controls - the App bar, Rangebase and Slider and some general controls the button. Chapter 11 takes dependency properties apart and there is no doubt that if you are going to master Silverlight development you need to understand dependency properties. Chapter 12 goes on to consider the most common use of dependency properties i.e. data binding.
Next we have some chapters on general graphics. Chapter 13 deals with vector graphics which in many ways is the most natural form of graphics in Silverlight. Chapter 14 explains bitmap graphics including WriteableBitmap and dynamic graphics. Chapter 15 is on animation - both simple and XAML based.
Chapter 16 goes back to core Silverlight facilities in the form of templates. Chapter 17 explains item controls, i.e. controls that display collections of items. This is, of course where databinding first becomes complicated.
The final chapter introduces the Pivot and Panorama controls and if the book has a flaw it is that these so important Phone only controls are left until so late in the book. The fact that they were released late in the development cycle is the most likley reason.
Overall this is an excellent introduction to creating applications for Windows Phone 7. For me the best part is where XNA and Silverlight are treated side by side. Later, however, what you have is a good introduction to Silverlight with lots of examples and explanations. This is not a re-write of the documentation but a presentation of how things work. It reduces the techno-speak of the manual to plain English - what more could you ask for.