Thông tin tài liệu
THE EXPERT’S VOICE
®
IN SILVERLIGHT
Pro
Business Applications
with Silverlight 4
Chris Anderson
Create rich business applications customized
to your needs quickly and efficiently
www.it-ebooks.info
www.it-ebooks.info
Pro Business Applications
with Silverlight 4
Chris Anderson
www.it-ebooks.info
Pro Business Applications with Silverlight 4
Copyright © 2010 by Chris Anderson
All rights reserved. No part of this work may be reproduced or transmitted in any form or by any
means, electronic or mechanical, including photocopying, recording, or by any information storage or
retrieval system, without the prior written permission of the copyright owner and the publisher.
ISBN-13 (pbk): 978-1-4302-7207-6
ISBN-13 (electronic): 978-1-4302-7206-9
Printed and bound in the United States of America 9 8 7 6 5 4 3 2 1
Trademarked names may appear in this book. Rather than use a trademark symbol with every
occurrence of a trademarked name, we use the names only in an editorial fashion and to the benefit of
the trademark owner, with no intention of infringement of the trademark.
President and Publisher: Paul Manning
Lead Editor: Jon Hassell
Technical Reviewer:
Editorial Board: Clay Andres, Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Cornell,
Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew Moodie, Duncan Parkes,
Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke, Dominic Shakeshaft,
Matt Wade, Tom Welsh
Coordinating Editor: Tracy Brown
Copy Editors: Julie Hammond, Damon Larson, Heather Lang, Kim Wimpsett.
Compositor: Bytheway Publishing Services
Indexer: Toma Mulligan
Artist: April Milne
Cover Designer: Anna Ishchenko
Distributed to the book trade worldwide by Springer-Verlag New York, Inc., 233 Spring Street, 6th
Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax 201-348-4505, e-mail
orders-ny@springer-
sbm.com, or visit www.springeronline.com.
For information on translations, please e-mail
rights@apress.com, or visit www.apress.com.
Apress and friends of ED books may be purchased in bulk for academic, corporate, or promotional
use. eBook versions and licenses are also available for most titles. For more information, reference our
Special Bulk Sales–eBook Licensing web page at
www.apress.com/info/bulksales.
The information in this book is distributed on an “as is” basis, without warranty. Although every
precaution has been taken in the preparation of this work, neither the author(s) nor Apress shall have
any liability to any person or entity with respect to any loss or damage caused or alleged to be caused
directly or indirectly by the information contained in this work.
The source code for this book is available to readers at
www.apress.com. You will need to answer
questions pertaining to this book in order to successfully download the code.
www.it-ebooks.info
For my grandmother Connie, a great role model for will power, optimism,
generousity, patience, and love. I miss her dearly.
www.it-ebooks.info
iv
Contents at a Glance
Contents at a Glance iv
Contents v
About the Author xix
Acknowledgments xx
Chapter 1: Introduction 1
Chapter 2: Getting Started with Silverlight 13
Chapter 3: An Introduction to XAML 35
Chapter 4: The Navigation Framework 73
Chapter 5: Exposing Data from the Server: Using WCF RIA Services 93
Chapter 6: Implementing Summary Lists 141
Chapter 7: Building Data Entry Forms 189
Chapter 8: Securing Your Application 245
Chapter 9: Styling Your Application 269
Chapter 10: Advanced XAML and Data Binding 287
Chapter 11: Creating Custom Controls 331
Chapter 12: The Model-View-ViewModel (MVVM) Design Pattern 373
Chapter 13: Printing and Reporting 403
Chapter 14: Out of Browser Mode, and Interacting with the
Operating System 427
Chapter 15: Application Deployment 483
Index 513
www.it-ebooks.info
v
Contents
Contents at a Glance iv
Contents v
About the Author xix
Acknowledgments xx
Chapter 1: Introduction 1
Who This Book Is For 1
About This Book 2
About the Author 3
Silverlight Overview 4
What Is Silverlight? 4
A Short History of Silverlight 6
What Can Silverlight Bring to Your Business Application? 7
When Should You Not Use Silverlight? 8
Comparing Silverlight to Other Microsoft Platforms 9
Comparison with Adobe Flash/Flex 11
Business Applications Overview 11
Summary 12
Chapter 2: Getting Started with Silverlight 13
Required Tools 13
Visual Studio 13
Expression Blend 4 and SketchFlow 14
www.it-ebooks.info
CONTENTS
vi
Silverlight 4 Tools 15
WCF RIA Services 15
Silverlight Toolkit 15
SQL Server 2008 Express Edition 15
Silverlight Spy (and .NET Reflector) 16
Creating a Silverlight Application 16
Silverlight Application 17
Silverlight Navigation Application 18
Silverlight Business Application 18
Silverlight Class Library 18
WCF RIA Services Class Library 19
Silverlight Unit Test Application 19
Running and Exploring the Default Silverlight Business Application Project 19
Exploring the Initial Silverlight Project Structure 22
Project Links 24
The Web Application Project Structure 26
The Silverlight Application Project Structure 28
Recommended Project Template Modifications 31
XAP Files 32
Summary 33
Chapter 3: An Introduction to XAML 35
Overcoming XAML’s Steep Learning Curve 35
Why Learn XAML? 36
XAML Syntax, Document Structure, and Features 37
Core XAML Syntax 37
Creating an Object Hierarchy 38
Namespaces 39
Assigning Property Values to Controls 41
www.it-ebooks.info
CONTENTS
vii
Attached Properties 44
XAML Namespace Properties 45
Design-Time Properties 46
Markup Extensions 47
Namescopes 49
Controls 50
Base Control Classes 51
Layout Controls 53
XAML vs. Windows Forms Controls’ Property Names 57
Assigning Event Handlers 58
Creating a Simple User Interface 60
Resources and Resource Dictionaries 62
Styles 64
Templates 65
Data Binding 65
Binding to an Object 66
Binding to a Collection 69
Designing User Experiences 70
The Designer/Developer Workflow 71
XAML User Interfaces: A Different Perspective 71
Summary 72
Chapter 4: The Navigation Framework 73
Getting Started with the Navigation Framework 73
Components of the Navigation Framework 75
The Frame Control 75
The Page Class 76
The NavigationService Object 76
The NavigationContext Object 77
www.it-ebooks.info
CONTENTS
viii
Navigating Between Views 77
View URIs 77
Navigation Methods on the Frame Control 78
Navigation Methods on the NavigationService Object 78
Using a HyperlinkButton Control 79
Using the Source Property of the Frame Control 79
User-Initiated Navigation 79
Passing Data Between Views 80
Passing Data Using Query String Parameters 80
Reading Query String Parameters 81
Passing Complex Data Types Between Views 82
Deep Links 82
URI Mapping to Enable Friendly URIs 83
Integrating with the Browser History 85
Handling Navigation Events 87
Frame Events 87
View Events 88
Caching Views 89
Visual Transition Effects 90
Alternative User Interface Frameworks 91
Summary 91
Chapter 5: Exposing Data from the Server: Using WCF RIA Services 93
What Is WCF RIA Services? 94
How the WCF RIA Services Code Generator Works 95
How Do You Use WCF RIA Services? 96
Linking Your Silverlight and Web Projects 97
Creating Your Domain Services 97
Creating Domain Operations on Your Domain Services 97
www.it-ebooks.info
[...]... for Silverlight applications to communicate with servers and pass data between them—making business applications easier to develop in Silverlight Silverlight 4: April 2010 Whereas Silverlight 3 immediately made creating business applications viable in Silverlight, Silverlight 4 smoothed many of the rough edges Silverlight 4 introduced printing capabilities (resolving a big complaint by business application... 48 3 Deploying the Application to the Server 48 3 xvii www.it-ebooks.info CONTENTS Server Requirements 48 4 Using Xcopy 48 5 Publishing 48 6 Creating a Web Package 48 7 Creating a Setup Program 48 8 Deploying the Application to the Client 48 8 The Default Silverlight Installation Process 48 9 Customizing... Frameworks 40 1 Summary .40 1 Chapter 13: Printing and Reporting 40 3 The Importance of Implementing Reporting 40 3 Potential Solutions for Implementing Reporting 40 4 Generating a PDF 40 4 Generating HTML 40 5 Generating Office Documents 40 5 Using Silverlight 4 Printing Functionality 40 5 Third-Party Report... reused with other applications) • It requires an additional download to run applications outside the browser (Adobe Air), and applications must be packaged separately to run in this runtime (whereas the same Silverlight application will run both within and outside the browser) Pros: Cons: Business Applications Overview Business applications sometimes also referred to as line-of -business (LOB) applications are... how to implement each in Silverlight to produce a complete end-to-end business application Summary Now that we’ve discussed both Silverlight and business applications separately, it’s time to put the two together and start learning how to build business applications in Silverlight 12 www.it-ebooks.info CHAPTER 2 Getting Started with Silverlight To start developing with Silverlight, you need to... Trust 46 4 Enabling Elevated Trust 46 5 File System Access 46 6 COM Automation 47 1 Custom Chrome 47 8 Other Restrictions Lifted By Elevated Trust 48 0 Restrictions Imposed by Elevated Trust 48 1 Disabling Elevated Trust Applications with a Windows Group Policy 48 1 Summary .48 2 Chapter 15:... 40 5 Office Integration Using COM 40 7 Choosing a Reporting Strategy 40 7 Printing Functionality in Silverlight 40 7 Generating and Displaying a PDF Report .40 9 Generating a Report on the Server 40 9 Displaying the Report on the Client 41 8 Summary .42 6 Chapter 14: Out of Browser Mode, and Interacting with the Operating... designing applications that communicate with a server clean and easy • You will be able to share code with Windows Phone 7 and WPF applications • Users can be set up with both the Silverlight runtime and your application with ease in a matter of minutes As you can see, Silverlight brings a lot to the table, and this book intends to demonstrate how it can lead to brilliant business applications However, Silverlight. .. .45 1 The Open File Dialog 45 2 The Save File Dialog 45 6 Drag Drop Target 45 9 Clipboard .46 0 Full Screen 46 2 Initiating Full Screen Mode 46 2 Detecting the Switch to and from Full Screen Mode 46 3 Retaining Full Screen Mode When Unfocused 46 3 Keyboard Access 46 4 Elevated... Customizing the Silverlight Installation Experience 49 0 Pushing the Silverlight Runtime to Users in the Enterprise 49 3 Building a Client Desktop Installer 49 4 Improving on the Default Application Loading Screen 49 5 Creating the Application Pre-loader Files 49 6 Designing the Application Pre-loader 49 7 Updating the Application Download Progress .
Pro Business Applications
with Silverlight 4
Chris Anderson
www.it-ebooks.info
Pro Business Applications with Silverlight. EXPERT’S VOICE
®
IN SILVERLIGHT
Pro
Business Applications
with Silverlight 4
Chris Anderson
Create rich business applications customized
Ngày đăng: 23/03/2014, 02:20
Xem thêm: Pro Business Applications with Silverlight 4 pptx, Pro Business Applications with Silverlight 4 pptx, XAML vs. Windows Forms Controls’ Property Names