SKIP THE SHIPPING
Use code NOSHIP during checkout to save 40% on eligible eBooks, now through January 5. Shop now.
Register your product to gain access to bonus material or receive a coupon.
Build Highly Usable, High-Performance Business Applications with Silverlight 5
Microsoft Silverlight MVP and Wintellect Consultant Jeremy Likness gives you all the hands-on guidance and proven patterns and practices you need to build scalable, maintainable, and highly professional applications for multiple platforms and browsers. In this first complete guide to designing Silverlight applications for commercial use, Likness focuses on the advanced Silverlight features most directly related to solving real-world business problems and demonstrates how these features fit together in production-quality applications.
Written from the ground up, this book covers every key area of enterprise Silverlight development. For each, Likness introduces the opportunities and capabilities Silverlight provides, offers relevant case studies from actual projects, presents complete C# code samples, and explains them in detail. Every chapter concludes with a summary highlighting the specific information and techniques most important for developers to consider.
Coverage includes
• Discovering why Silverlight is superior to HTML5/JavaScript for most line-of-business applications
• Leveraging Silverlight 5’s powerful enhancements to performance, text, printing, usability, security, and programmability
• Effectively applying Silverlight’s application cycle in enterprise applications
• Using XAML to drive Silverlight’s visual interface
• Quickly transforming raw data into visually appealing information
• Using Silverlight’s innovative Visual State Manager and data binding to separate design, UI/UX experience, and business logic
• Simplifying development with the MVVM pattern
• Using MEF to integrate modular code into highly extensible, maintainable, and testable Silverlight applications
• Improving and automating testing with Silverlight Unit Testing Framework and third-party add-ons
• Mastering each leading approach to navigation and implementing the best one for your application
• Implementing the service layer, persistence, and state management
• Building advanced “out-of-browser” applications
• Integrating sophisticated line-of-business features into your solutions
• Optimizing the performance of your Silverlight applications
This book will be invaluable for all experienced client developers who use Microsoft’s technology stack and want to leverage Silverlight’s immense power; and for every Silverlight developer seeking to improve existing line-of-business applications with the new Silverlight 5.
Designing Silverlight Business Applications: the Model-View-ViewModel (MVVM)
Download the sample pages (includes Chapter 7 and Index)
Foreword xviii
Preface xx
Acknowledgments xxx
About the Author xxxii
Chapter 1 Silverlight 1
The Common Language Runtime (CLR) 1
The Base Class Library (BCL) 2
The Presentation Core 3
The Presentation Framework 3
Communications 4
Data 4
Key Differences from the Full CLR 5
Silverlight First 6
WPF and Silverlight 7
HTML5 8
HTML5 Is Not Ready for Line of Business 10
HTML5 Won’t Keep Pace 11
HTML5 Isn’t Just Markup 12
HTML5 Is Not Native 12
HTML5 Is the Perfect Technology 14
Which Client Technology Is Right for You? 14
Use What You Know 15
Listen to the Customer 15
Consider the Development Team 16
Analyze Third-party Dependencies 17
LOB Applications 18
Summary 19
Chapter 2 Getting Started 21
Setting Up Your Environment 21
Silverlight 5 SDK and Visual Studio Tools 22
Expression Blend SDK 22
Silverlight Toolkit 24
Open Source Projects 25
Hello, Silverlight 26
Creating the Silverlight Application 27
Class Libraries 29
Application Services 32
Creating the Extension XAP 41
Sharing between Silverlight and the Core Framework 48
What about Those Templates? 53
The Standard Solution 55
Web Host 55
The Silverlight Project 59
Anatomy of a XAP File 61
Summary 64
Chapter 3 Extensible Application Markup Language (Xaml) 67
Markup and Class Instantiation 68
Dependency Objects and Properties 70
Dependency Properties 71
Attached Properties 75
Value Precedence 76
Markup Extensions 76
Type Converters 81
Value Converters 84
Styles 86
Storyboards 91
Layout 95
Measure and Arrange 96
Canvas 96
Grid 97
StackPanel 101
VirtualizingPanel and VirtualizingStackPanel 103
Containers 104
ContentControl 104
ItemsControl 105
ScrollViewer 105
ViewBox 106
Basic Controls 108
Summary 111
Chapter 4 Advanced Xaml 113
Working with Text 114
Rich Text 114
Character Spacing 120
Line Height 121
Parts, States, and Templates 123
Parts 123
States 127
Data Templates 128
Design-time Extensions 132
Interactivity with Behaviors and Triggers 141
Behaviors 141
Triggers 147
Natural User Interface (NUI) 149
Resource Dictionaries and Isolating Themes 151
Embedding and Distributing Fonts 155
Tips for XAP Extensions 157
Summary 159
Chapter 5 The Visual State Manager 161
Introduction to the VSM 162
Groups 162
States 165
Transitions 170
The Visual State Manager Workflow 171
Advanced Troubleshooting and Events 172
Custom Visual State Managers 176
The Visual State Manager in Blend 177
The Visual State Aggregator 185
Summary 194
Chapter 6 Data-Binding 195
Data-Binding Basics 196
Data-Binding Debugging 200
Data-Binding within Styles 203
Synchronizing Lists 208
Commands 218
Validation 220
Validation with Exceptions 224
Validation Using Data Error Info 226
Asynchronous Validation 230
Fluent Validation 232
Summary 244
Chapter 7 Model-View-ViewModel (MVVM) 245
UI Design Patterns 246
The Model-View-ViewModel Pattern 251
The Model 255
The View 262
The View Model 264
Binding the View Model to the View 265
View Model Locators 265
Controllers 269
Design-Time View Models 271
Custom Markup Extensions 272
View-Model-First Approach Versus View-First Approach 274
Lists and Data Elements 275
Summary 276
Chapter 8 The Managed Extensibility Framework (MEF) 279
Discovery 281
Imports 281
Exports 284
Parts 286
Catalogs 287
Containers 288
Composition Initializer and Host 289
Lifetime Management 291
Extensibility 295
Recomposition 297
Deployment Catalog 301
Discovering XAP Files 303
Offline Catalog 305
Metadata 306
Weakly Typed Metadata 306
Strongly Typed Metadata 309
Lazy<T,TMetadata> 312
Troubleshooting 313
Understanding Stable Composition 314
Import Parameters 315
The MEF Debugger 316
Jounce, an MVVM with MEF Framework 318
Summary 319
Chapter 9 Testing 321
Why Test? 322
Testing Eliminates Assumptions 323
Testing Kills Bugs at the Source 324
Testing Helps Document Code 324
Testing Makes Extending and Maintaining Applications Easier 325
Testing Improves Architecture and Design 326
Testing Makes Better Developers 326
Conclusion: You Should Test 327
Unit Tests 327
Silverlight Unit Testing Framework 332
Linked Classes and Shared Testing 338
Automated Testing 343
Mocking and MEF 345
View Model Tests 352
Testing Xaml 359
Coded UI Tests 364
Challenges 366
Automation Peers 367
Summary 371
Chapter 10 Navigation 373
The Silverlight Navigation Framework 374
Basics of Navigation Using the Framework 375
Choosing Page-Based Navigation 377
Custom Navigation 378
Manual Navigation 379
Containers 379
Navigation Events 384
Region Management 391
Summary 398
Chapter 11 The Service Layer 399
Domain Data and Behaviors 400
Strategies for Sharing Domain Objects between the Client and Server 401
DOM Interop and ASP.NET Callbacks 402
The Updated To-Do List 402
DOM Interoperability 404
Another Example: Callbacks 407
Communication 412
Representational State Transfer (REST) 412
Plain Old XML (POX) and JavaScript Object Notation (JSON) 423
Windows Communication Foundation (WCF) 424
WCF RIA Services 431
Local Messages 435
Sockets 436
Mapping and Transformation 443
Mapping Versus Exposing the Model 443
Dynamic Types 448
The Custom Type Provider 450
Asynchronous Techniques 452
Events Versus the Asynchronous Programming Model (APM) 452
Lambda Expressions and Method Chaining 455
Action and Callbacks 456
Reactive Extensions (Rx) 459
IWorkflow 460
Tasks and await 463
Summary 465
Chapter 12 Persistence and State Management 467
The To-Do List Application 468
WCF RIA Services 468
Filters and Sorts 471
Navigation Parameters 472
Persisting Preferences with Settings 473
Folders and Files in Isolated Storage 476
Managing Isolated Storage Access and Quotas 478
Accessing Folders and Files 482
Finding Isolated Storage 484
Iterating the File System 485
Signing Files 491
Encrypting Files in Silverlight 494
Sterling in Silverlight 498
Summary 514
Chapter 13 Out of Browser Applications 515
Getting Started 516
Checking for Updates 523
Elevated Trust 526
Application Signing 528
File System Access 530
Toast Notifications 531
Child Windows 535
COM Interop and Script Host 540
Native Silverlight Extensions 546
p/Invoke 547
Elevated Trust in the Browser 552
Distribution and Installation 553
Installation 553
Execution 554
Uninstalling Your OOB Application 555
Summary 556
Chapter 14 Line of Business Features 557
Designer/Developer Workflow 559
Printing 561
Localization 571
Modularity and Extensibility 576
Scalability 578
Extremely Large Data Sets 578
Concurrency 590
Synchronization 593
Proof of Concept 594
Summary 596
Chapter 15 Debugging and Performance Optimization 597
Debugging Silverlight Applications 598
Debug Symbols 600
Debugging Tips 602
Debugging Applications Already Launched 608
WinDbg 611
Logging and Tracing 616
Client Logging and Tracing 617
WCF Tracing 619
Profiling Applications with Visual Studio 622
Fiddler 625
Silverlight Spy 626
Summary 627
Glossary 629
Index 653