You are previewing Pro Business Applications with Silverlight 4.
O'Reilly logo
Pro Business Applications with Silverlight 4

Book Description

Silverlight 4 has the potential to revolutionize the way we build business applications. With its flexibility, web deployment, cross-platform capabilities, rich .NET language support on the client, rich user interface control set, small runtime, and more, it comes close to the perfect platform in which to build business applications. It's a very powerful technology, and despite its relative youth, it's moving forward at a rapid pace and is gaining widespread adoption.

This book will guide you through the process of designing and developing enterprise-strength business applications in Silverlight 4 and C#. You will learn how to take advantage of the power of Silverlight to develop rich and robust business applications, from getting started to deployment, and everything in between.

In particular, this book will serve developers who want to learn how to design business applications, and tackle the issues that you'll face, and how to resolve them. Chris Anderson demonstrates his experience through a candid presentation of how to approach real-life implementation decisions.

With this book in hand, you will

  • Create a fully functional business application in Silverlight

  • Discover how to satisfy all of the common requirements that most business applications share

Table of Contents

  1. Copyright
  2. About the Author
  3. Acknowledgments
  4. 1. Introduction
    1. 1.1. Who This Book Is For
    2. 1.2. About This Book
    3. 1.3. About the Author
    4. 1.4. Silverlight Overview
      1. 1.4.1. What Is Silverlight?
        1. 1.4.1.1. Market Penetration/Reach
        2. 1.4.1.2. Focus
        3. 1.4.1.3. Compatibility
        4. 1.4.1.4. Windows Phone 7
        5. 1.4.1.5. The Silverlight Runtime
        6. 1.4.1.6. Out-of-Browser (OOB) Experiences
      2. 1.4.2. A Short History of Silverlight
        1. 1.4.2.1. Silverlight 1: September 2007
        2. 1.4.2.2. Silverlight 2: October 2008
        3. 1.4.2.3. Silverlight 3: July 2009
        4. 1.4.2.4. Silverlight 4: April 2010
      3. 1.4.3. What Can Silverlight Bring to Your Business Application?
      4. 1.4.4. When Should You Not Use Silverlight?
        1. 1.4.4.1. Comparing Silverlight Applications to HTML-Based Applications
        2. 1.4.4.2. Comparing Silverlight Applications to Rich Desktop Applications
      5. 1.4.5. Comparing Silverlight to Other Microsoft Platforms
        1. 1.4.5.1. WPF
        2. 1.4.5.2. Windows Forms
        3. 1.4.5.3. ASP.NET
      6. 1.4.6. Comparison with Adobe Flash/Flex
    5. 1.5. Business Applications Overview
    6. 1.6. Summary
  5. 2. Getting Started with Silverlight
    1. 2.1. Required Tools
      1. 2.1.1. Visual Studio
      2. 2.1.2. Expression Blend 4 and SketchFlow
      3. 2.1.3. Silverlight 4 Tools
      4. 2.1.4. WCF RIA Services
      5. 2.1.5. Silverlight Toolkit
      6. 2.1.6. SQL Server 2008 Express Edition
      7. 2.1.7. Silverlight Spy (and .NET Reflector)
    2. 2.2. Creating a Silverlight Application
      1. 2.2.1. Silverlight Application
      2. 2.2.2. Silverlight Navigation Application
      3. 2.2.3. Silverlight Business Application
      4. 2.2.4. Silverlight Class Library
      5. 2.2.5. WCF RIA Services Class Library
      6. 2.2.6. Silverlight Unit Test Application
    3. 2.3. Running and Exploring the Default Silverlight Business Application Project
    4. 2.4. Exploring the Initial Silverlight Project Structure
      1. 2.4.1. Project Links
      2. 2.4.2. The Web Application Project Structure
      3. 2.4.3. The Silverlight Application Project Structure
    5. 2.5. Recommended Project Template Modifications
    6. 2.6. XAP Files
    7. 2.7. Summary
  6. 3. An Introduction to XAML
    1. 3.1. Overcoming XAML's Steep Learning Curve
    2. 3.2. Why Learn XAML?
    3. 3.3. XAML Syntax, Document Structure, and Features
      1. 3.3.1. Core XAML Syntax
      2. 3.3.2. Creating an Object Hierarchy
      3. 3.3.3. Namespaces
      4. 3.3.4. Assigning Property Values to Controls
        1. 3.3.4.1. Attribute Syntax
        2. 3.3.4.2. Content Element Syntax
        3. 3.3.4.3. Property Element Syntax
        4. 3.3.4.4. Collection Syntax
      5. 3.3.5. Attached Properties
      6. 3.3.6. XAML Namespace Properties
        1. 3.3.6.1. x:Class
        2. 3.3.6.2. x:Name
        3. 3.3.6.3. x:Key
        4. 3.3.6.4. x:ClassModifier and x:FieldModifier
      7. 3.3.7. Design-Time Properties
      8. 3.3.8. Markup Extensions
      9. 3.3.9. Namescopes
    4. 3.4. Controls
      1. 3.4.1. Base Control Classes
        1. 3.4.1.1. DependencyObject
        2. 3.4.1.2. UIElement
        3. 3.4.1.3. FrameworkElement
        4. 3.4.1.4. Control
        5. 3.4.1.5. ContentControl
      2. 3.4.2. Layout Controls
        1. 3.4.2.1. Canvas
        2. 3.4.2.2. Grid
          1. 3.4.2.2.1. Weighted Proportion Sizing
          2. 3.4.2.2.2. Fixed-Width Sizing
          3. 3.4.2.2.3. Automatic Sizing
          4. 3.4.2.2.4. Assigning Controls to Grid Cells
        3. 3.4.2.3. Stack Panel
        4. 3.4.2.4. Silverlight Toolkit Layout Controls
      3. 3.4.3. XAML vs. Windows Forms Controls' Property Names
      4. 3.4.4. Assigning Event Handlers
        1. 3.4.4.1. Assigning Event Handlers in XAML in Visual Studio
        2. 3.4.4.2. Assigning Event Handlers in XAML in Expression Blend
        3. 3.4.4.3. Routed vs. Direct Events
        4. 3.4.4.4. Assigning Event Handlers in Code
      5. 3.4.5. Creating a Simple User Interface
    5. 3.5. Resources and Resource Dictionaries
    6. 3.6. Styles
    7. 3.7. Templates
    8. 3.8. Data Binding
      1. 3.8.1. Binding to an Object
      2. 3.8.2. Binding to a Collection
    9. 3.9. Designing User Experiences
    10. 3.10. The Designer/Developer Workflow
    11. 3.11. XAML User Interfaces: A Different Perspective
    12. 3.12. Summary
  7. 4. The Navigation Framework
    1. 4.1. Getting Started with the Navigation Framework
    2. 4.2. Components of the Navigation Framework
      1. 4.2.1. The Frame Control
      2. 4.2.2. The Page Class
      3. 4.2.3. The NavigationService Object
      4. 4.2.4. The NavigationContext Object
    3. 4.3. Navigating Between Views
      1. 4.3.1. View URIs
      2. 4.3.2. Navigation Methods on the Frame Control
      3. 4.3.3. Navigation Methods on the NavigationService Object
      4. 4.3.4. Using a HyperlinkButton Control
      5. 4.3.5. Using the Source Property of the Frame Control
      6. 4.3.6. User-Initiated Navigation
    4. 4.4. Passing Data Between Views
      1. 4.4.1. Passing Data Using Query String Parameters
      2. 4.4.2. Reading Query String Parameters
      3. 4.4.3. Passing Complex Data Types Between Views
    5. 4.5. Deep Links
    6. 4.6. URI Mapping to Enable Friendly URIs
    7. 4.7. Integrating with the Browser History
    8. 4.8. Handling Navigation Events
      1. 4.8.1. Frame Events
      2. 4.8.2. View Events
    9. 4.9. Caching Views
    10. 4.10. Visual Transition Effects
    11. 4.11. Alternative User Interface Frameworks
    12. 4.12. Summary
  8. 5. Exposing Data from the Server: Using WCF RIA Services
    1. 5.1. What Is WCF RIA Services?
    2. 5.2. How the WCF RIA Services Code Generator Works
    3. 5.3. How Do You Use WCF RIA Services?
      1. 5.3.1. Linking Your Silverlight and Web Projects
      2. 5.3.2. Creating Your Domain Services
      3. 5.3.3. Creating Domain Operations on Your Domain Services
      4. 5.3.4. Consuming the Domain Services
    4. 5.4. Getting Started
    5. 5.5. Creating a Data Access Layer Using the Entity Framework
      1. 5.5.1. Configuring the Database
      2. 5.5.2. About the Entity Framework
      3. 5.5.3. Creating an Entity Model
    6. 5.6. Domain Services
      1. 5.6.1. Understanding the Domain Service Life Cycle
      2. 5.6.2. Creating a Domain Service
        1. 5.6.2.1. Entity Selection
        2. 5.6.2.2. Enabling Client Access
        3. 5.6.2.3. Exposing an OData Endpoint
        4. 5.6.2.4. Generating Associated Classes for Metadata
        5. 5.6.2.5. Creating the ProductService Domain Service
    7. 5.7. Domain Operations
      1. 5.7.1. Query Operations
        1. 5.7.1.1. Returning a Collection of Entities
        2. 5.7.1.2. Returning a Single Entity
        3. 5.7.1.3. Naming/Signature Convention
      2. 5.7.2. Insert/Update/Delete Operations
        1. 5.7.2.1. Naming/Signature Convention
        2. 5.7.2.2. Example Insert/Update/Delete Operations
      3. 5.7.3. Invoke Operations
        1. 5.7.3.1. Naming/Signature Convention
        2. 5.7.3.2. An Example Invoke Operation
      4. 5.7.4. Custom Operations
        1. 5.7.4.1. Naming/Signature Convention
        2. 5.7.4.2. An Example Custom Operation
    8. 5.8. Decorating Entities
      1. 5.8.1. Metadata Classes
      2. 5.8.2. Controlling Client Entity Generation
        1. 5.8.2.1. Including/Excluding Properties
        2. 5.8.2.2. Including/Excluding Associated Entities
        3. 5.8.2.3. Enabling Associated Entities to Be Editable
      3. 5.8.3. Validation
        1. 5.8.3.1. Predefined Validation Attributes
        2. 5.8.3.2. Custom Property Validation Attributes
        3. 5.8.3.3. Custom Class Validation Attributes
      4. 5.8.4. Presentation
      5. 5.8.5. Miscellaneous Data Annotations
    9. 5.9. Presentation Model Types
      1. 5.9.1. Creating the Presentation Model Class
      2. 5.9.2. Populating and Exposing Your Presentation Model Types
      3. 5.9.3. Updating Your Presentation Model Types
    10. 5.10. Sharing Code/Logic Across Tiers
    11. 5.11. Inspecting the Generated Code in the Silverlight Project
    12. 5.12. Encapsulating Logic in a Separate WCF RIA Services Class Library
    13. 5.13. Handling Server Errors
    14. 5.14. Handling Data Concurrency Violations
      1. 5.14.1. Methods of Identifying Concurrency Violations
      2. 5.14.2. Configuring the Entity Model to Check for Concurrency Violations
      3. 5.14.3. Testing Your Solution
      4. 5.14.4. Resolving Conflicts in the Domain Service
    15. 5.15. Transactions
    16. 5.16. WCF RIA Services Toolkit
    17. 5.17. Alternative Communication Technologies
      1. 5.17.1. WCF Services
        1. 5.17.1.1. Configuring Bindings
        2. 5.17.1.2. Consuming a WCF Service
        3. 5.17.1.3. Common Pitfalls
          1. 5.17.1.3.1. Maximum Message Size
          2. 5.17.1.3.2. ASP.NET Session State
        4. 5.17.1.4. Sharing Code, Business Objects, and Logic Between the Server and Client
      2. 5.17.2. WCF Data Services
        1. 5.17.2.1. Data Services vs. RIA Services
        2. 5.17.2.2. Using Data Services
      3. 5.17.3. HTTP Requests
        1. 5.17.3.1. Making an HTTP Request
        2. 5.17.3.2. Choosing a Networking Stack
      4. 5.17.4. Sockets
    18. 5.18. Summary
  9. 6. Implementing Summary Lists
    1. 6.1. Exposing a Summary Collection from the Server
    2. 6.2. Collections and Collection Views
      1. 6.2.1. ObservableCollection<T>
      2. 6.2.2. Views
        1. 6.2.2.1. The CollectionViewSource
        2. 6.2.2.2. The PagedCollectionView
        3. 6.2.2.3. DomainDataSourceView
    3. 6.3. Consuming Data from the Server
      1. 6.3.1. Understanding the Domain Context
      2. 6.3.2. XAML-Based Approach
      3. 6.3.3. Code-Based Approach
      4. 6.3.4. Choosing the Right Approach
      5. 6.3.5. Explicitly Specifying a Domain Service Host
      6. 6.3.6. Using the BusyIndicator Control
    4. 6.4. Displaying the Summary List
      1. 6.4.1. Retrieving the Data from the Server
        1. 6.4.1.1. The XAML-Based Approach
        2. 6.4.1.2. The Code-Based Approach
      2. 6.4.2. Configuring and Customizing a Control for Displaying Data
        1. 6.4.2.1. Configuring and Customizing a DataGrid Control
          1. 6.4.2.1.1. Configuring DataGrid Columns
          2. 6.4.2.1.2. Creating Column Definitions the Easy Way
          3. 6.4.2.1.3. Displaying an Image in a Column
          4. 6.4.2.1.4. Creating Calculated Columns
          5. 6.4.2.1.5. Editing Data in the DataGrid
          6. 6.4.2.1.6. Additional Built-In Behaviors
        2. 6.4.2.2. Configuring and Customizing a ListBox Control
          1. 6.4.2.2.1. Templating List Items
          2. 6.4.2.2.2. Customizing the Layout of the Items
          3. 6.4.2.2.3. Limitations of the ListBox Control
      3. 6.4.3. Choosing the Right Control
    5. 6.5. Manipulating Summary Lists
      1. 6.5.1. Querying Data Exposed by a Domain Operation
      2. 6.5.2. Filtering the Summary List
        1. 6.5.2.1. DomainDataSource Method
        2. 6.5.2.2. Domain Context Method
        3. 6.5.2.3. PagedCollectionView Method
      3. 6.5.3. Sorting the Summary List
        1. 6.5.3.1. DomainDataSource Method
        2. 6.5.3.2. Domain Context Method
        3. 6.5.3.3. PagedCollectionView Method
      4. 6.5.4. Grouping the Summary List
        1. 6.5.4.1. DomainDataSource Method
        2. 6.5.4.2. Domain Context Method
        3. 6.5.4.3. PagedCollectionView Method
      5. 6.5.5. Paging the Summary List
        1. 6.5.5.1. DomainDataSource Method
        2. 6.5.5.2. Domain Context Method
        3. 6.5.5.3. PagedCollectionView Method
    6. 6.6. Drilling Down on a Record
      1. 6.6.1. Opening Details in a New View
      2. 6.6.2. Opening Details in a Pop-Up Window
      3. 6.6.3. Displaying Details Using the DataGrid's Row Details
      4. 6.6.4. Implementing a Master/Details View
    7. 6.7. Handling Errors
    8. 6.8. Summary
  10. 7. Building Data Entry Forms
    1. 7.1. Creating the Data Entry User Interface
      1. 7.1.1. Laying Out the Data Entry Form
        1. 7.1.1.1. Using the Data Sources Window
        2. 7.1.1.2. Using XAML Power Toys
        3. 7.1.1.3. Using the DataForm Control
          1. 7.1.1.3.1. Creating a DataForm Control with Automatically Generated Fields
          2. 7.1.1.3.2. Creating a DataForm Control with Explicitly Defined Fields
          3. 7.1.1.3.3. Configuring the Labels
          4. 7.1.1.3.4. The Cancel Button
          5. 7.1.1.3.5. The AutoEdit and AutoCommit Properties
          6. 7.1.1.3.6. Customizing the Header
      2. 7.1.2. Refining the Data Entry Form's Functionality
        1. 7.1.2.1. Data Input Controls
          1. 7.1.2.1.1. The TextBox Control
          2. 7.1.2.1.2. The CheckBox Control
          3. 7.1.2.1.3. The RadioButton Control
          4. 7.1.2.1.4. The ComboBox Control
          5. 7.1.2.1.5. The List Control
          6. 7.1.2.1.6. The Date Input Controls
          7. 7.1.2.1.7. The Time Input Controls
          8. 7.1.2.1.8. The Up/Down Controls
          9. 7.1.2.1.9. The AutoCompleteBox Control
          10. 7.1.2.1.10. The Label Control
        2. 7.1.2.2. Setting the Tab Order
        3. 7.1.2.3. Setting Focus
        4. 7.1.2.4. Getting Focused Control
        5. 7.1.2.5. Checking Whether Items Have Changed
      3. 7.1.3. Using the DataGrid for Data Entry
        1. 7.1.3.1. Adding a Row
        2. 7.1.3.2. Inserting a Row
        3. 7.1.3.3. Spreadsheet-Like Editing
        4. 7.1.3.4. Maintaining an Empty Row for the Entry of New Records
        5. 7.1.3.5. Deleting the Selected Rows
        6. 7.1.3.6. Adding a Delete Button to Each Row
    2. 7.2. Structuring Objects for Use by Data Entry Forms
      1. 7.2.1. Implementing the INotifyPropertyChanged Interface
        1. 7.2.1.1. Basic Implementation (with "Magic Strings")
        2. 7.2.1.2. Using Reflection Instead of Magic Strings
        3. 7.2.1.3. Using Reflection to Validate Magic Strings in Debug Mode
        4. 7.2.1.4. Using Lambda Expressions Instead of Magic Strings
      2. 7.2.2. Implementing the IEditableObject Interface
        1. 7.2.2.1. Implementing the BeginEdit Method
        2. 7.2.2.2. Implementing the EndEdit Method
        3. 7.2.2.3. Implementing the CancelEdit Method
          1. 7.2.2.3.1. Manually Assigning Property Values
          2. 7.2.2.3.2. Assigning Property Values Using Reflection
        4. 7.2.2.4. Using the IEditableObject Methods
      3. 7.2.3. Adding Calculated Properties to Your Classes
    3. 7.3. Data Validation
      1. 7.3.1. Displaying Validation Errors
        1. 7.3.1.1. Data Entry Controls
        2. 7.3.1.2. The ValidationSummary Control
        3. 7.3.1.3. The DataForm Control
        4. 7.3.1.4. The DataGrid Control
      2. 7.3.2. Types of Data Validation
      3. 7.3.3. Defining Validation Rules
      4. 7.3.4. Exposing Validation Errors to the User Interface
        1. 7.3.4.1. Validation by Exception
        2. 7.3.4.2. The IDataErrorInfo Interface
        3. 7.3.4.3. The INotifyDataErrorInfo Interface
        4. 7.3.4.4. Deciding Which Method to Use
      5. 7.3.5. Notifying the User Interface of Object-Level Validation Errors
      6. 7.3.6. The Validator Class
        1. 7.3.6.1. Validating Properties
        2. 7.3.6.2. Validating Objects
      7. 7.3.7. Customizing Validation Attribute Error Messages
    4. 7.4. Submitting Changes to the Server
      1. 7.4.1. Change-Tracking
      2. 7.4.2. Submitting Changes via the DomainDataSource Control
      3. 7.4.3. Submitting Changes via a Domain Context
      4. 7.4.4. Handling Errors
      5. 7.4.5. Handling Concurrency Violations
    5. 7.5. Summary
  11. 8. Securing Your Application
    1. 8.1. Implementing Server-Side Security Using RIA Services
      1. 8.1.1. The ASP.NET Membership API
      2. 8.1.2. Configuring Your Database for Forms Authentication
      3. 8.1.3. Authentication
      4. 8.1.4. Requiring Authentication
      5. 8.1.5. Role-Based Operation Access Restrictions
      6. 8.1.6. Returning a Subset of Data Based on the User's ID or Role
      7. 8.1.7. Permitting Update/Delete Operations According to Data
      8. 8.1.8. Exposing Custom User Profile Data
      9. 8.1.9. User Registration
      10. 8.1.10. Avoiding SQL Injection Attacks
      11. 8.1.11. Sanitizing Errors Sent to the Client
    2. 8.2. Implementing Client-Side Security
      1. 8.2.1. Authenticating and Registering Users
      2. 8.2.2. Accessing and Updating User Information
      3. 8.2.3. Implementing Client-Side Restrictions
      4. 8.2.4. Storing Data Locally
    3. 8.3. Encrypting Data Passed Between the Server and the Client
    4. 8.4. Cross-Domain Access Policies
      1. 8.4.1. Implementing Cross-Domain Policies for HTTP-Based Communication
      2. 8.4.2. Implementing Cross-Domain Policies for Socket-Based Communication
      3. 8.4.3. Implementing Cross-Scheme Access Policies
    5. 8.5. Restricting Access to Your Application
    6. 8.6. Summary
  12. 9. Styling Your Application
    1. 9.1. The Designer/Developer Workflow
    2. 9.2. Defining Style Resources
      1. 9.2.1. Defining a Style Resource
        1. 9.2.1.1. Explicit Styles
        2. 9.2.1.2. Implicit Styles
      2. 9.2.2. Defining Style Resources at Various Locations
        1. 9.2.2.1. At the View Level
        2. 9.2.2.2. At the Application Level
        3. 9.2.2.3. As a Resource Dictionary
        4. 9.2.2.4. As a Resource Dictionary in a Referenced Assembly
        5. 9.2.2.5. In Generic.xaml
      3. 9.2.3. Naming Style Resources
      4. 9.2.4. Inheriting Style Resources
      5. 9.2.5. Styling Constraints
    3. 9.3. Control Templates
      1. 9.3.1. Default Control Templates
      2. 9.3.2. Templating a Control
      3. 9.3.3. Control Template Structure
        1. 9.3.3.1. Visual States
        2. 9.3.3.2. State Transitions
        3. 9.3.3.3. Visual State Groups
        4. 9.3.3.4. Template Parts
    4. 9.4. Theming
      1. 9.4.1. Creating a Custom Theme
      2. 9.4.2. Silverlight Toolkit Themes
      3. 9.4.3. Silverlight Navigation/Business Application Themed Project Templates
    5. 9.5. Icons and Images
    6. 9.6. Animation
    7. 9.7. Pixel Shaders / Effects
    8. 9.8. Miscellaneous Styling Tips
      1. 9.8.1. Defining Constants in XAML
      2. 9.8.2. Restoring a Control's Default Style
    9. 9.9. Summary
  13. 10. Advanced XAML and Data Binding
    1. 10.1. Advanced XAML
      1. 10.1.1. Comments in XAML
      2. 10.1.2. Defining Constants
      3. 10.1.3. Using OR to Combine Enumerated Values in XAML
      4. 10.1.4. Triggers, Actions, and Behaviors
        1. 10.1.4.1. Using Predefined Triggers and Actions
          1. 10.1.4.1.1. Adding the Required Assembly References
          2. 10.1.4.1.2. Understanding how Triggers and Actions Interact
          3. 10.1.4.1.3. Configuring Triggers and Actions using Expression Blend
          4. 10.1.4.1.4. Implementing Triggers and Actions by Hand in XAML
        2. 10.1.4.2. Creating a Custom Trigger
        3. 10.1.4.3. Creating a Custom Action
        4. 10.1.4.4. Creating and Using Behaviors
        5. 10.1.4.5. Which Should I Use?
      5. 10.1.5. Blendability
        1. 10.1.5.1. The Design-Time Data Mechanisms
        2. 10.1.5.2. Defining the Shape of the Data
        3. 10.1.5.3. Using Sample Data
      6. 10.1.6. Creating Consolidated Namespaces
      7. 10.1.7. MoXAML Power Toys
    2. 10.2. Advanced Data Binding
      1. 10.2.1. Assigning the Source of a Binding
        1. 10.2.1.1. Using the Binding's Source Property
        2. 10.2.1.2. ElementName Binding
        3. 10.2.1.3. RelativeSource Binding
        4. 10.2.1.4. Binding a Control Property to its Data Context
        5. 10.2.1.5. Binding to a Property in the View's Code-Behind
      2. 10.2.2. Binding to a Resource
        1. 10.2.2.1. Creating a Class to Bind To
        2. 10.2.2.2. Instantiating the Class as a Resource in XAML
        3. 10.2.2.3. Binding to the Resource
        4. 10.2.2.4. Automatically Creating and Binding the Resource Using the Data Sources Window
      3. 10.2.3. Defining Resources in the Code-Behind (For Binding To)
      4. 10.2.4. Binding to Nested Properties
      5. 10.2.5. Binding to Indexed Properties
      6. 10.2.6. Binding to Collection Views
        1. 10.2.6.1. Binding to Objects in a PagedCollectionView
          1. 10.2.6.1.1. Creating the Object Collection
          2. 10.2.6.1.2. Instantiating the Class as a Resource and Binding to It
          3. 10.2.6.1.3. How Does This Example Work?
        2. 10.2.6.2. Binding to Objects in a CollectionViewSource
      7. 10.2.7. Enhancing Data Binding
        1. 10.2.7.1. String Formatting
        2. 10.2.7.2. Alternative Value When a Source Property Value is Null
        3. 10.2.7.3. Fallback Values
        4. 10.2.7.4. UpdateSourceTrigger
        5. 10.2.7.5. Value Converters
          1. 10.2.7.5.1. Creating a Simple Value Converter
          2. 10.2.7.5.2. Using a Value Converter
          3. 10.2.7.5.3. Passing a Parameter to the Value Converter
          4. 10.2.7.5.4. Passing a Culture to a Value Converter
          5. 10.2.7.5.5. Passing an Entire Object to a Value Converter
      8. 10.2.8. Data Binding in Code
      9. 10.2.9. Getting and Setting Attached Property Values in Code
      10. 10.2.10. Additional Tips
        1. 10.2.10.1. Visual Studio 2010 Data Binding Expression Builder
        2. 10.2.10.2. Debugging Data Binding Issues
        3. 10.2.10.3. Binding Using Property Element Syntax
        4. 10.2.10.4. MultiBinding
    3. 10.3. Summary
  14. 11. Creating Custom Controls
    1. 11.1. Adding Functionality to an Existing Control
    2. 11.2. Creating User Controls
      1. 11.2.1. Creating a Simple User Control
      2. 11.2.2. Exposing Properties
        1. 11.2.2.1. Standard Properties
        2. 11.2.2.2. Dependency Properties
          1. 11.2.2.2.1. Why Do We Need Dependency Properties?
          2. 11.2.2.2.2. Registering a Dependency Property
          3. 11.2.2.2.3. Getting and Setting a Dependency Property Value
          4. 11.2.2.2.4. Creating a Standard CLR Property Wrapper
          5. 11.2.2.2.5. Dependency Property Metadata
          6. 11.2.2.2.6. Value Precedence
          7. 11.2.2.2.7. Simplifying Creating Dependency Properties
          8. 11.2.2.2.8. Obtaining the Local Value
          9. 11.2.2.2.9. Resetting a Dependency Property's Value
          10. 11.2.2.2.10. Dependency Properties in Summary
        3. 11.2.2.3. Consuming the Property Values in Your Control
        4. 11.2.2.4. Type Converters
        5. 11.2.2.5. Implementing the ISupportInitialize Interface
      3. 11.2.3. Exposing Methods
      4. 11.2.4. Exposing Events
      5. 11.2.5. Determining If in Design-Time or Runtime Mode
      6. 11.2.6. Constraining the User Control's Size
    3. 11.3. Creating Custom Controls
      1. 11.3.1. Creating the Custom Control
      2. 11.3.2. The Control Structure
      3. 11.3.3. Defining the Control's Default Template
        1. 11.3.3.1. Creating/Editing the Control Template in Expression Blend
        2. 11.3.3.2. Creating the Base State
        3. 11.3.3.3. Identifying States and Organizing Them Into State Groups
        4. 11.3.3.4. Implementing the States
        5. 11.3.3.5. Adding State Transition Animations
        6. 11.3.3.6. Defining Template Parts
        7. 11.3.3.7. Binding to Properties in the Code
          1. 11.3.3.7.1. One-Way Binding with the TemplateBinding Markup Extension
          2. 11.3.3.7.2. Two-Way Binding Using the RelativeSource Markup Extension
        8. 11.3.3.8. Splitting Your Generic.xaml File Into Smaller Pieces
      4. 11.3.4. Defining the Control's Behavior
        1. 11.3.4.1. Defining the Contract
        2. 11.3.4.2. Connecting the Code and the Default Control Template
        3. 11.3.4.3. Handling Events for Elements Defined in the Control Template (in the Code)
        4. 11.3.4.4. Transitioning Between States
        5. 11.3.4.5. Implementing the WaitIndicator's Behavior
        6. 11.3.4.6. Testing the Control
    4. 11.4. Content Controls
      1. 11.4.1. Containing a Single Control as Content
      2. 11.4.2. Containing Multiple Controls as Content
      3. 11.4.3. Attached Properties
    5. 11.5. Summary
  15. 12. The Model-View-ViewModel (MVVM) Design Pattern
    1. 12.1. The Purpose of Implementing MVVM
    2. 12.2. Why You Should Implement MVVM
    3. 12.3. MVVM Theory
      1. 12.3.1. The Layers
        1. 12.3.1.1. Views
        2. 12.3.1.2. Models
        3. 12.3.1.3. View Models
      2. 12.3.2. View / View Model Configurations
        1. 12.3.2.1. One View Model Serving Multiple Views
        2. 12.3.2.2. One View Interacting with Multiple View Models
    4. 12.4. MVVM in Practice
      1. 12.4.1. Creating the Layers
        1. 12.4.1.1. Creating the View
        2. 12.4.1.2. Creating the Model
        3. 12.4.1.3. Creating the View Model
      2. 12.4.2. Connecting the Layers
        1. 12.4.2.1. Connecting the Models to the View Models
        2. 12.4.2.2. Connecting the View Model to the View
      3. 12.4.3. View and ViewModel Interactions
        1. 12.4.3.1. Pulling Data into the View from the ViewModel
        2. 12.4.3.2. Enabling the View to Invoke an Operation (Method) on the View Model
          1. 12.4.3.2.1. Actions/Behaviors
          2. 12.4.3.2.2. Commands
          3. 12.4.3.2.3. Actions/Behaviors vs. Commands
        3. 12.4.3.3. Enabling the View to Respond to an Event in the View Model
      4. 12.4.4. Layer Interaction Summary
      5. 12.4.5. Hotly Debated Implementation Details
        1. 12.4.5.1. Should Model Objects be Exposed Directly to the View?
        2. 12.4.5.2. Should View Models Copy Data to and from the Models?
        3. 12.4.5.3. What Should Come First, the View or the View Model?
          1. 12.4.5.3.1. ViewModel First
          2. 12.4.5.3.2. View First
          3. 12.4.5.3.3. Completely Decoupled
        4. 12.4.5.4. Should I Use a MVVM Framework?
        5. 12.4.5.5. Should I Implement Dependency Properties or Standard Properties?
    5. 12.5. MVVM and RIA Services
      1. 12.5.1. Implementing the Model
      2. 12.5.2. Implementing the View Model
      3. 12.5.3. Implementing the View
    6. 12.6. Frameworks
    7. 12.7. Summary
  16. 13. Printing and Reporting
    1. 13.1. The Importance of Implementing Reporting
    2. 13.2. Potential Solutions for Implementing Reporting
      1. 13.2.1. Generating a PDF
      2. 13.2.2. Generating HTML
      3. 13.2.3. Generating Office Documents
      4. 13.2.4. Using Silverlight 4 Printing Functionality
      5. 13.2.5. Third-Party Report Viewers
        1. 13.2.5.1. Perpetuum Software's Report Sharp-Shooter for Silverlight
        2. 13.2.5.2. Telerik's Telerik Reporting
        3. 13.2.5.3. DevExpress's XtraReports Suite
        4. 13.2.5.4. First Floor Software's Document Toolkit + Aspose Converter
      6. 13.2.6. Office Integration Using COM
    3. 13.3. Choosing a Reporting Strategy
    4. 13.4. Printing Functionality in Silverlight
    5. 13.5. Generating and Displaying a PDF Report
      1. 13.5.1. Generating a Report on the Server
        1. 13.5.1.1. Choosing a Reporting Tool/Engine
        2. 13.5.1.2. Choosing an Output Format
        3. 13.5.1.3. Serving Reports to the Client
          1. 13.5.1.3.1. Solution Overview
          2. 13.5.1.3.2. Creating the HTTP Handler
          3. 13.5.1.3.3. Creating a Report Renderer
          4. 13.5.1.3.4. Returning Data to Populate the Report
          5. 13.5.1.3.5. Securing Access to the Report
          6. 13.5.1.3.6. Deploying the Report Viewer/Engine
      2. 13.5.2. Displaying the Report on the Client
        1. 13.5.2.1. Creating the HtmlViewer Control
          1. 13.5.2.1.1. Solution Overview
          2. 13.5.2.1.2. The HTML Bridge
          3. 13.5.2.1.3. Steps to Overlaying an IFrame on Your Application
          4. 13.5.2.1.4. Additional Features and Functionality
        2. 13.5.2.2. Using the HtmlViewer Control
    6. 13.6. Summary
  17. 14. Out of Browser Mode, and Interacting with the Operating System
    1. 14.1. Out of Browser
      1. 14.1.1. Configuring OOB Mode
        1. 14.1.1.1. Window Options
        2. 14.1.1.2. Install Options
        3. 14.1.1.3. Miscellaneous Options
      2. 14.1.2. Installing the Application to Run Out of Browser
      3. 14.1.3. Determining Installation Status
      4. 14.1.4. Determining Whether Running Inside or Outside the Browser
      5. 14.1.5. Where/How is the Application's .xap File Stored and Run?
      6. 14.1.6. Interacting with the OOB Window
        1. 14.1.6.1. Closing the Window
        2. 14.1.6.2. Window State, Position and Dimensions
        3. 14.1.6.3. Other
      7. 14.1.7. Checking for Updates
      8. 14.1.8. Debugging Out of Browser
      9. 14.1.9. Uninstalling the Application
      10. 14.1.10. Toast Notifications
    2. 14.2. Caching Data Locally
      1. 14.2.1. Caching to Isolated Storage
        1. 14.2.1.1. Storing Settings in Isolated Storage
          1. 14.2.1.1.1. Persisting a Value to Isolated Storage
          2. 14.2.1.1.2. Retrieving a Value from Isolated Storage
          3. 14.2.1.1.3. Binding to Settings
          4. 14.2.1.1.4. Enumerating the Settings
          5. 14.2.1.1.5. Removing Settings
        2. 14.2.1.2. Storing Files in Isolated Storage
          1. 14.2.1.2.1. Opening an Isolated Storage Store
          2. 14.2.1.2.2. Working with Directories
          3. 14.2.1.2.3. Enumerating Through Files and Directories
          4. 14.2.1.2.4. Working with Files
          5. 14.2.1.2.5. Writing a Text File
          6. 14.2.1.2.6. Writing a Binary File
          7. 14.2.1.2.7. Reading a Text File
          8. 14.2.1.2.8. Reading a Binary File
          9. 14.2.1.2.9. Serializing an Object to a File
          10. 14.2.1.2.10. Deserializing and Rehydrating an Object from File
        3. 14.2.1.3. Disk Space Quota
        4. 14.2.1.4. Encrypting Data
        5. 14.2.1.5. Compressing Data
        6. 14.2.1.6. The Sync Framework
      2. 14.2.2. Caching to a Client-Side Database
        1. 14.2.2.1.
          1. 14.2.2.1.1. Sterling
          2. 14.2.2.1.2. Silverlight Database (SilverDB)
          3. 14.2.2.1.3. SQLite
          4. 14.2.2.1.4. Sharp HSql
          5. 14.2.2.1.5. Commercial Options
          6. 14.2.2.1.6. Communicating with Local Database Engines
      3. 14.2.3. Detecting Network Connection Availability
    3. 14.3. File System Open/Save Dialogs
      1. 14.3.1. The Open File Dialog
        1. 14.3.1.1. Displaying the Dialog
        2. 14.3.1.2. Filtering the Files
        3. 14.3.1.3. Opening and Reading the Selected File
          1. 14.3.1.3.1. Opening and Reading Text Files
          2. 14.3.1.3.2. Opening and Reading Binary Files
        4. 14.3.1.4. Enabling Multiple File Selection
      2. 14.3.2. The Save File Dialog
        1. 14.3.2.1. Displaying the Dialog
        2. 14.3.2.2. Setting a Default Extension
        3. 14.3.2.3. Writing to the File
          1. 14.3.2.3.1. Writing a Text File
          2. 14.3.2.3.2. Writing a Binary File
    4. 14.4. Drag Drop Target
    5. 14.5. Clipboard
    6. 14.6. Full Screen
      1. 14.6.1. Initiating Full Screen Mode
      2. 14.6.2. Detecting the Switch to and from Full Screen Mode
      3. 14.6.3. Retaining Full Screen Mode When Unfocused
      4. 14.6.4. Keyboard Access
    7. 14.7. Elevated Trust
      1. 14.7.1. Enabling Elevated Trust
      2. 14.7.2. File System Access
        1. 14.7.2.1. Getting the Path of a Special Folder
        2. 14.7.2.2. Enumerating Files and Directories within a Folder
        3. 14.7.2.3. Determining Whether a File or Folder Exists
        4. 14.7.2.4. Reading Data from a File
        5. 14.7.2.5. Saving Data to a File
        6. 14.7.2.6. Appending Text to a File
        7. 14.7.2.7. Creating a New Folder
        8. 14.7.2.8. Deleting a File
        9. 14.7.2.9. Copying or Moving a File
        10. 14.7.2.10. Accessing File/Folder Attributes
      3. 14.7.3. COM Automation
        1. 14.7.3.1. Determining Whether COM Automation is Available
        2. 14.7.3.2. Accessing COM Components
        3. 14.7.3.3. Determining Whether a COM Component is Available
        4. 14.7.3.4. Using the Windows Script Host Object
        5. 14.7.3.5. Reading and Writing Files
        6. 14.7.3.6. Automating Office Applications
        7. 14.7.3.7. Handling COM Events
        8. 14.7.3.8. Communicating with Local Databases
        9. 14.7.3.9. Accessing Local Hardware Devices
        10. 14.7.3.10. Creating and Installing your own COM Component
      4. 14.7.4. Custom Chrome
        1. 14.7.4.1. Moving the Window
        2. 14.7.4.2. Resizing the Window
      5. 14.7.5. Other Restrictions Lifted By Elevated Trust
      6. 14.7.6. Restrictions Imposed by Elevated Trust
      7. 14.7.7. Disabling Elevated Trust Applications with a Windows Group Policy
    8. 14.8. Summary
  18. 15. Application Deployment
    1. 15.1. Deploying the Application to the Server
      1. 15.1.1. Server Requirements
        1. 15.1.1.1. Server Operating System and Web Server
        2. 15.1.1.2. RIA Services
          1. 15.1.1.2.1. Installing RIA Services Assemblies to the GAC
          2. 15.1.1.2.2. Installing RIA Services Assemblies to the Bin Directory
        3. 15.1.1.3. Cross-Domain Policy File
      2. 15.1.2. Using Xcopy
      3. 15.1.3. Publishing
      4. 15.1.4. Creating a Web Package
      5. 15.1.5. Creating a Setup Program
    2. 15.2. Deploying the Application to the Client
      1. 15.2.1. The Default Silverlight Installation Process
      2. 15.2.2. Customizing the Silverlight Installation Experience
        1. 15.2.2.1. Why You Should Customize the Silverlight Installation Experience
        2. 15.2.2.2. Seeing What the User Sees Without Silverlight Installed
        3. 15.2.2.3. Implementing a Custom Landing Page
        4. 15.2.2.4. Further Guidance
      3. 15.2.3. Pushing the Silverlight Runtime to Users in the Enterprise
      4. 15.2.4. Building a Client Desktop Installer
    3. 15.3. Improving on the Default Application Loading Screen
      1. 15.3.1. Creating the Application Pre-loader Files
      2. 15.3.2. Designing the Application Pre-loader
      3. 15.3.3. Updating the Application Download Progress
      4. 15.3.4. Configuring the Application Pre-loader in the HTML File
      5. 15.3.5. Testing the Application Pre-loader
        1. 15.3.5.1. Adding a Large File to the Silverlight Project
        2. 15.3.5.2. Not Assigning the Application's RootVisual
        3. 15.3.5.3. Using Fiddler
    4. 15.4. Partitioning Your Application
      1. 15.4.1. Initial Steps
      2. 15.4.2. Assembly Caching
        1. 15.4.2.1. Why Use Assembly Caching
        2. 15.4.2.2. How Assembly Caching Works
        3. 15.4.2.3. Enabling Your Own Assemblies to be Cached
      3. 15.4.3. Downloading Modules on Demand
        1. 15.4.3.1. Downloading Modules on Demand Using Prism
        2. 15.4.3.2. Downloading Modules on Demand Using MEF
        3. 15.4.3.3. Downloading Modules on Demand Using the Navigation Framework
    5. 15.5. Digitally Signing Your Application
    6. 15.6. Summary