Create a fully functional Lecrenski Join the discussion @ p2p.wrox.com Wrox Programmer to Programmer™ application using Silverlight 4 Silverlight 4 boasts long-awaited features that conquer writing a Rich Internet Application. Using new line-of-business features in S this book, you create a web application that’s more responsive than a traditional ASP.NET web site. Leveraging new features and the i improved Silverlight Toolkit, in each chapter you’ll work through l the problem statement, design analysis, and solution implementation. v Silverlight 4: Problem–Design–Solution: wrox.com (cid:129) E xplains how to determine functional requirements for your site e (cid:129) D etails the latest features, such as charting, enhanced data entry Programmer r controls, navigation framework, and element to element binding Forums l (cid:129) C overs the new Silverlight Toolkit featuring themes, charting, and Join our Programmer to layout management i Programmer forums to ask g (cid:129) U ses the new .NET RIA Services for your middle tier and data access layers and answer programming questions about this book, (cid:129) U tilizes existing Silverlight ASP.NET membership, authentication, join discussions on the h and profile services hottest topics in the industry, and connect with fellow (cid:129) I llustrates adding social networking to the application using a programmers from around t Silverlight based MySpace application the world. ™ (cid:129) A ddresses generating revenue with Pay-Per-Click advertisements Code Downloads from Google AdSense™ and recurring monthly subscriptions using 4 the PayPal® developer API Take advantage of free code samples from this book, as (cid:129) S hows how to leverage the ASP.NET AJAX Control Toolkit to well as code samples from Silverlight 4 incorporate HTML content into a Silverlight application hundreds of other books, all ™ (cid:129) I ncludes step-by-step deployment instructions to host the site ready to use. with a real shared hosted provider, Discount ASP.NET Read More Find articles, ebooks, sample Nick Lecrenski is the founder and lead developer of MyFitnessJournal.com, chapters and tables of contents Problem a popular fitness tracking web site developed entirely in Silverlight. for hundreds of books, and more reference resources on Design Problem - Design - Solution Wrox Problem – Design – Solution references give you solid, workable solutions programming topics that matter to real-world development problems. Each chapter is devoted to a different to you. Solution scenario, analyzing every problem, examining relevant design issues, and implementing the ideal solution. $49.99 USA Nick Lecrenski Web Development/ASP.NET $59.99 CAN www.it-ebooks.info Related Wrox Books ASP.NET MVC 1.0 Test Driven Development Problem – Design – Solution ISBN: 978-0-470-44762-8 A hands-on guide to creating a complete ASP.NET site using Test Driven Development methods. Shows how ASP.NET MVC is well Programmer to Programmer™ suited to TDD and testability. Covers the complete lifecycle including design, testing, deployment, beta releases, refactoring, and tool and framework selection. ASP.NET MVC 1.0 Website Programming Problem – Design – Solution Get more out of ISBN: 978-0-470-41095-0 A hands-on guide to creating ASP.NET websites using MVC. The book solves some of the most common problems that programmers run into when creating their first application or when trying to upgrade a current application to this new technology, and demonstrates each concept while building TheBeerHouse application. wrox.com Beginning ASP.NET MVC 1.0 ISBN: 978-0-470-43399-7 This book is a great choice for those who already have ASP.NET knowledge and need to grasp the new concepts of ASP.NET MVC. Readers will learn about Test-Driven Development and unit testing, the principles of the MVC pattern and its role in TDD, how to implement the pattern and how to move from traditional ASP.NET webforms to ASP.NET MVC. The book also includes detailed case studies that can be applied in real world situations. Professional ASP.NET 3.5 AJAX ISBN: 978-0-470-39217-1 This book is aimed at experienced ASP.NET developers looking to add AJAX to their applications, and experienced Web developers Interact Join the Community who want to move to using ASP.NET and AJAX together. Take an active role online by participating in our Sign up for our free monthly newsletter at Professional ASP.NET 4: in C# and VB P2P forums @ p2p.wrox.com newsletter.wrox.com ISBN: 978-0-470-50220-4 Written by three highly recognized and regarded ASP.NET experts, this book provides all-encompassing coverage on ASP.NET 4 and offers a unique approach of featuring examples in both C# and VB, as is the incomparable coverage of core ASP.NET. After a fast- Wrox Online Library Browse paced refresher on essentials such as server controls, the book delves into expert coverage of all the latest capabilities of ASP.NET 4. You’ll learn site navigation, personalization, membership, role management, security, and more. Hundreds of our books are available online Ready for more Wrox? We have books and Professional ASP.NET MVC 1.0 through Books24x7.com e-books available on .NET, SQL Server, Java, ISBN: 978-0-470-38461-9 XML, Visual Basic, C#/ C++, and much more! This book begins with you working along as Scott Guthrie builds a complete ASP.NET MVC reference application, NerdDinner.com. He begins by starting a new project and incrementally adding functionality and features. Along the way you’ll cover how to create Wrox Blox a database, build a model layer with business rule validations, implement listing/details data browsing, provide CRUD (Create, Update, Delete) data form entry support, reuse UI using master pages and partials, secure the application using authentication and Download short informational pieces and code authorization, and implement automated unit testing. From there, the bulk of the rest of the book goes into the ways that MVC is to keep you up to date and out of trouble! different from ASP.NET Web Forms, exploring the structure of a standard MVC application and see what you get out of the box. The last third of the book focuses entirely on advanced techniques and extending the framework. Silverlight 3 Programmer’s Reference ISBN: 978-0-470-38540-1 This valuable reference—in full color—explains this release of Silverlight 3 which makes the development of powerful Rich Interactive Applications (RIAs) achievable for everyone. Packed with examples and written by a highly-seasoned team of developers and designers, this book guides you through the languages, tools, and techniques that are used to build applications on the Silverlight 3 platform. Contact Us. WPF Programmer’s Reference: Windows Presentation Foundation with C# 2010 and .NET 4 ISBN: 978-0-470-47722-9 We always like to get feedback from our readers. Have a book idea? Written by a leading expert on Microsoft graphics programming, this richly illustrated book provides an introduction to WPF Need community support? Let us know by e-mailing [email protected] development and explains fundamental WPF concepts. www.it-ebooks.info Silverlight™ 4 Problem – DeSign – Solution introDuction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .xv chaPter 1 FitnessTrackerPlus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .1 chaPter 2 Prepare to Be Popular . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19 chaPter 3 Sign Me Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 chaPter 4 Welcome Home . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .141 chaPter 5 One More Slice Can’t Hurt . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193 chaPter 6 Time to Hit the Gym . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .233 chaPter 7 Am I Working Hard Enough? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .279 chaPter 8 Unfinished Business . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 313 chaPter 9 Sharing Your Success . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .349 chaPter 10 Social Networking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .387 chaPter 11 This Site Doesn’t Run Itself . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .423 chaPter 12 Let’s Go Live . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .463 inDex . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .489 www.it-ebooks.info 534045ffirs.indd 1 3/16/10 9:35:31 AM www.it-ebooks.info 534045ffirs.indd 2 3/16/10 9:35:31 AM Silverlighttm 4 Problem – Design – solution Nick Lecrenski www.it-ebooks.info 534045ffirs.indd 3 3/16/10 9:35:31 AM Silverlighttm 4: Problem – Design – Solution Published by Wiley Publishing, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 www.wiley.com Copyright © 2010 by Wiley Publishing, Inc., Indianapolis, Indiana Published simultaneously in Canada ISBN: 978-0-470-53404-5 Manufactured in the United States of America 10 9 8 7 6 5 4 3 2 1 No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ 07030, (201) 748-6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions. Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or pro- motional materials. The advice and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a competent professional person should be sought. Neither the pub- lisher nor the author shall be liable for damages arising herefrom. The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does not mean that the author or the publisher endorses the information the organization or Web site may provide or recommendations it may make. Further, readers should be aware that Internet Web sites listed in this work may have changed or disappeared between when this work was written and when it is read. For general information on our other products and services please contact our Customer Care Department within the United States at (877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002. Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic books. Library of Congress Control Number: 2009940875 Trademarks: Wiley, the Wiley logo, Wrox, the Wrox logo, Programmer to Programmer, and related trade dress are trade- marks or registered trademarks of John Wiley & Sons, Inc. and/or its affiliates, in the United States and other countries, and may not be used without written permission. Silverlight is a trademark of Microsoft Corporation in the United States and/or other countries. All other trademarks are the property of their respective owners. Wiley Publishing, Inc., is not associated with any product or vendor mentioned in this book. www.it-ebooks.info 534045ffirs.indd 4 3/16/10 9:35:31 AM This book is dedicated to my beautiful wife Kristie, my daughter Tabetha, and our newest addition to the family, baby Cheyenne. Without their collective patience over the last nine months this book would not have been possible. — Nick LecreNski www.it-ebooks.info 534045ffirs.indd 5 3/16/10 9:35:31 AM creDitS acquiSitionS eDitor vice PreSiDent anD executive grouP Paul Reese PubliSher Richard Swadley Project eDitor Maureen Spears vice PreSiDent anD executive PubliSher Barry Pruett technical eDitor Jonathan Marbutt aSSociate PubliSher Jim Minatel ProDuction eDitorS Tim Tate Project coorDinator, cover Amy Weintraub Lynsey Stanford coPy eDitor comPoSitor Nancy Rappaport Craig Johnson, Happenstance Type-O-Rama eDitorial Director ProofreaDerS Robyn B . Siesky Josh Chase, Word One Carrie Hunter, Word One Scott Klemp, Word One eDitorial manager Mary Beth Wakefield inDexer Johnna VanHoose Dinse aSSociate Director of marketing David Mayhew cover DeSign Michael E . Trent ProDuction manager Tim Tate cover image © Valueline/Punchstock www.it-ebooks.info 534045ffirs.indd 6 3/16/10 9:35:31 AM about the author nick lecrenSki is a developer with 10 years of experience in a wide range of Microsoft technologies including Visual C++, C#, VB, VB.NET, SQL Server, .NET Framework, ASP.NET, AJAX, Silverlight and more. He has a BS in Computer Science and has worked in various fields from biometrics to financial services. He is also the founder/lead developer of MyFitnessJournal.com, a fitness training website that currently utilizes Silverlight technology and has thousands of registered users. about the technical eDitor jonathan marbutt is Vice President of Development for WayCool Software, Inc. based in Birmingham, AL. He has been working professionally in software development since 1996 and has covered various Microsoft technologies from VB6 to .NET. Over the recent years, Jonathan developed using Silverlight to build Rich Internet Line-of-Business applications for the non-profit sector. Through this development, he’s focused on User Experience (UX) by utilizing Microsoft products such as Expression Blend and technologies such as Silverlight. You can contact Jonathan at http://www.jmtechware.com. www.it-ebooks.info 534045ffirs.indd 7 3/16/10 9:35:31 AM acknowleDgmentS writing a technical book like thiS one is an eye-opening experience. For years, I have been on the other side as the reader of hundreds of books on topics ranging from video game programming to the latest version of ASP.NET. I’ve never given much thought about how much work actually goes into the writing and producing one of those aforementioned books. Now, as a first-time writer who has completed his first book, I can safely say I’ll never take the hard work that authors and publishers perform for granted again. With that said, I want to take the time to thank everyone who helped to make this book possible. First, I want to thank my wife, who despite being pregnant with a due date scheduled right smack in the middle of writing this book, continued to encourage the work that I was doing and put up with many weekends of marathon writing sessions. Needless to say, my chore list has grown since the book started. Next, I want to thank my daughter Tabetha, who I could only take to one Mets game this year because of my busy schedule. Luckily, the team was terrible so it wasn’t much of a sacrifice. Completing a book like this one involves months of hard work from not just me but also the hard- working team at Wrox Press. I can’t even begin to convey just how dedicated and professional the Wrox Press team is when it comes to publishing new books but I will make an attempt by thanking those who were directly involved in the completion and success of Silverlight 4 Problem-Design- Solution. For starters, I want to thank Maureen Spears who was the Project Editor for this book. As a first time writer, it is imperative to be paired with an editor who has a lot of patience. Luckily, I had Maureen on my side throughout the process. Whether it was a breaking change in a beta release or some other crazy issue threatening to sabotage me from hitting a deadline, Maureen was always the calm voice of reason that would assure me that there was nothing to worry about and these things happen all the time. More often than not, just knowing that I wasn’t the only writer to hit these roadblocks was usually enough to get me to the next milestone. In addition to Maureen, I also had a wonderful Copy Editor in Nancy Rappaport, who no doubt had her hands full with this project. Thanks to her diligent work, the chapters make logical sense and are grammatically correct. As a full-time software developer, grammar isn’t always the first thing on my mind when I write. Of course, although my full-time focus is on programming, when you write a technical book it is vital to have the content reviewed by another professional software developer to ensure that the author doesn’t lose the audience along the way. My Technical Editor, Jonathan Marbutt, was an invaluable resource, ensuring that the chapter code not only compiled but also by reviewing the topics discussed in the accompanying chapter. Finally, I want to thank the two people from Wrox who made this book possible in the first place. Thanks to Paul Reese, the Acquisitions Editor, who from the very beginning was there to help me convert my idea for a book into a real proposal that would eventually kick off the project. Lastly, I’d like to thank Jim Minatel, the Associate Publisher, who I first contacted with the idea. Thanks again, Paul and Jim, for taking the time to listen to my original idea, for providing me with this great opportunity, and for taking a chance on this first-time writer. www.it-ebooks.info 534045ffirs.indd 8 3/16/10 9:35:31 AM