Contents

Contents at a Glance

About the Author

About the Technical Reviewers

Acknowledgments

Introduction

Chapter 1: Getting Started with Silverlight

Collecting the Required Tools

Visual Studio

Expression Blend 5 and SketchFlow

Silverlight 5 Tools

WCF RIA Services

Silverlight Toolkit

SQL Server 2008 R2 Express Edition

Silverlight Spy (and .NET Reflector)

Working with the Silverlight Project Templates

Silverlight Application

Silverlight Navigation Application

Silverlight Business Application

Silverlight Class Library

WCF RIA Services Class Library

Silverlight Unit Test Application

Workshop: Creating a Silverlight Project

Exploring the Base Silverlight Business Application

Exploring the Initial Silverlight Project Structure

Project Links

The Web Application Project Structure

The Silverlight Application Project Structure

Recommended Project Template Modifications

Understanding XAP Files

Summary

Chapter 2: An Introduction to XAML

Overcoming XAML's Steep Learning Curve

Why Learn XAML?

Understanding XAML Syntax, Document Structure, and Features

Core XAML Syntax!

Creating an Object Hierarchy

Defining Namespaces

Assigning Property Values to Controls

Attached Properties

XAML Namespace Properties

Design-Time Properties

Markup Extensions

Namescopes

Controls

Layout Controls

XAML vs. Windows Forms Controls' Property Names

Assigning Event Handlers

Workshop: Creating a Simple User Interface

Working with Resources and Resource Dictionaries

Defining and Referencing Resources

Resource Dictionaries

Applying Styles

Defining a Style Resource

Applying the Style to a Control

Introducing Templates

Data Binding

Setting the Source of a Binding

Workshop: Binding to an Object

Binding to a Collection

Designing User Experiences

Enhancing the Designer/Developer Workflow

Designing XAML User Interfaces from a Different Perspective

Summary

Chapter 3: The Navigation Framework

Getting Started with the Navigation Framework

Exploring the Components of the Navigation Framework

The Frame Control

The Page Class

The NavigationService Object

The NavigationContext Object

Navigating Between Views

Using View URIs

Navigating using the Frame Control

Navigating using the NavigationService Object

Using a HyperlinkButton Control

Using the Source Property of the Frame Control

User-Initiated Navigation

Passing Data Between Views

Passing Data Using Query String Parameters

Reading Query String Parameters

Passing Complex Data Types Between Views

Working with Deep Links

Enabling Friendly URIs with URI Mapping

Integrating with the Browser History

Handling Navigation Events

Frame Events

View Events

Caching Views

Workshop: Practicing with Views and Navigation

Part 1: Creating a New View

Part 2: Passing Data Between Views

Part 3: Mapping a URI

Applying Visual Transition Effects

Creating Custom Content Loaders

Working with Alternative User Interface Frameworks

Summary

Chapter 4: Exposing Data from the Server

Why Expose Data from the Server via Services

Creating a Data Access Layer Using the Entity Framework

Configuring the Database

About the Entity Framework

Workshop: Creating an Entity Model

WCF Services

A Short Overview of WCF

The Silverlight-Enabled WCF Service Item Template

Supported Bindings

Sharing Code and Business Objects Between the Server and Client

Workshop: Creating a WCF Service

WCF RIA Services

What Is WCF RIA Services?

An Overview of How to Use WCF RIA Services

How the WCF RIA Services Code Generator Works

Creating the RIA Services Link

Domain Services

Domain Operations

Decorating Entities

Presentation Model Types

Sharing Code and Logic Across Tiers

Encapsulating Logic in a Separate WCF RIA Services Class Library

Handling Errors

Handling Data Concurrency Violations

Transactions

WCF RIA Services Toolkit

The WCF RIA Services Contrib Project

WCF Data Services

Duplex Communication (Pull + Push)

Summary

Chapter 5: Consuming Data from the Server

Communicating Asynchronously

Consuming Data from the Server Using WCF Services

Workshop: Querying Data Exposed by a WCF Service

Common Pitfalls

Consuming Data from the Server Using RIA Services

Inspecting the Generated Code in the Silverlight Project

Consuming Data Declaratively in XAML via the DomainDataSource Control

Consuming Data in Code via the Domain Context Class

Choosing the Right Approach

Specifying Query Criteria

Explicitly Specifying a Domain Service Host

Handling Load Errors

Submitting Changes to the Server Using RIA Services

Change Tracking

Workshop: Submitting Changes via a Domain Context

Handling Submit Errors

Handling Concurrency Violations

HTTP Requests

Making an HTTP Request

Choosing a Networking Stack

Cross-Domain Access Policies

Implementing Cross-Domain Policies for HTTP-Based Communication

Implementing Cross-Domain Policies for Socket-Based Communication

Implementing Cross-Scheme Access Policies

Summary

Chapter 6: Implementing Summary Lists

Creating the Summary List

Using the DataGrid Control

Using the ListBox Control

Choosing the Right Control

Populating a Summary List with Data

The ObservableCollection<T> Type

Collection Views

Binding a Summary List to a DomainDataSource Control

Binding a Summary List to a View Model Class

Manipulating Summary List's Contents

Workshop: Filtering the Summary List

Workshop: Sorting the Summary List

Workshop: Grouping the Summary List

Workshop: Paging the Summary List

Using the BusyIndicator Control

Displaying the BusyIndicator Control

Customizing the BusyIndicator Control's Content

Modal Behavior

The DisplayAfter Property

Drilling Down on a Record

Navigating to the Details View

Opening Details in a Pop-Up Window

Displaying Details Using the DataGrid's Row Details

Implementing a Master/Details View

Summary

Chapter 7: Building Data Entry Forms

Creating the Data Entry User Interface

Laying Out the Data Entry Form

Refining the Data Entry Form's Functionality

Using the DataGrid for Data Entry

Structuring Objects for Use by Data Entry Forms

Implementing the INotifyPropertyChanged Interface

Implementing the IEditableObject Interface

Adding Calculated Properties to Your Classes

Data Validation

Displaying Validation Errors

Types of Data Validation

Defining Validation Rules

Reporting Validation Errors from Objects

Exposing Object-Level Validation Errors

Handling Validation Errors in Your View's Code-Behind

Executing Validation Rules Implemented as Attributes

Customizing Validation Attribute Error Messages

Complex Validation Rules

Workshop: Creating a Master/Details Screen

Summary

Chapter 8: Securing Your Application

Implementing Server-Side Security Using RIA Services

Using the ASP.NET Membership API

Configuring Your Database for Forms Authentication

Setting Up Authentication

Requiring Authentication

Restricting Access to Operations by Role

Returning a Subset of Data Based on the User's ID or Role

Permitting Update/Delete Operations According to Data

Exposing Custom User Profile Data

Registering Users

Avoiding SQL Injection Attacks

Sanitizing Errors Sent to the Client

Workshop: Practicing with Server-Side Security

Implementing Client-Side Security

Authenticating and Registering Users

Accessing and Updating User Information

Implementing Client-Side Restrictions

Storing Data Locally

Workshop: Practicing with Client-Side Security

Encrypting Data Passed Between the Server and the Client

Restricting Access to Your Application

Summary

Chapter 9: Styling Your Application

Considering the Designer/Developer Workflow

Defining Style Resources

Defining a Style Resource

Defining Style Resources in the Object Hierarchy

Storing Complex Property Values in Styles

Naming Style Resources

Inheriting Style Resources

Styling Constraints

Applying Control Templates

Using Default Control Templates

Templating a Control

Structuring Control Templates

Theming

Creating a Custom Theme

Using Silverlight Toolkit Themes

Installing Silverlight Navigation and Business Application Themed Project Templates

Effectively Using Icons and Images

Applying Animation

Applying Pixel Shaders and Effects

Miscellaneous Styling Tips

Defining Constants in XAML

Finding a Control's Style Definition

Applying a Style to a Control Using the XAML Designer

Restoring a Control's Default Style

Binding in Style Setters

Summary

Chapter 10: Advanced XAML

Ignoring Elements and Attributes

Comments in XAML

Commenting Out Elements

Commenting Out Attributes

Nesting Comments

Defining “Constants”

Using OR to Combine Enumerated Values in XAML

Triggers, Actions, and Behaviors

Using Predefined Triggers and Actions

Workshop: Writing Custom Triggers

Workshop: Creating and Using Custom Actions

Behaviors

Which Should I Use?

Custom Markup Extensions

Creating a Custom Markup Extension

Extending the Binding Markup Extension

Services

Advanced Markup Extension Behavior

Workshop: Implementing the Custom Markup Extension

Blendability

The Design-Time Data Mechanisms

Defining the Shape of the Data

Using Sample Data

Creating Consolidated Namespaces

MoXAML Power Toys

XAML Extensions for Visual Studio 2010

XAML IntelliSense Presenter

XAML Regions

XAML Styler

Xaml Formatter

Summary

Chapter 11: Advanced Data Binding

Assigning the Source of a Binding

Using the Binding's Source Property

ElementName Binding

RelativeSource Binding

Binding a Control Property Directly to Its Data Context

Detecting When the DataContext's Value Has Changed

Binding to a Property in the View's Code Behind

Instantiating a Class in XAML

Creating a Class to Bind To

Instantiating the Class as a Resource in XAML and Binding to It

Instantiating the Class as the Value of a Control's Property

Defining Resources in the Code Behind

Binding to Nested Properties

Binding to Indexed Properties

Binding to Dynamic Properties

Enhancing Data Binding

String Formatting

Alternative Value When a Source Property Value Is Null

Fallback Values

UpdateSourceTrigger

Value Converters

Binding Using Property Element Syntax

MultiBinding

Data Binding in Code

Getting and Setting Attached Property Values in Code

Additional Tips

Visual Studio Data Binding Expression Builder

Using the Data Sources Tool Window to Create a Resource and Controls That Bind to It

Debugging Data Binding Issues

Commands

Creating a Command

Binding to a Command

Passing a Parameter to a Command

The DelegateCommand

Summary

Chapter 12: Creating User Controls and Custom Controls

Adding Functionality to an Existing Control

Creating User Controls

Workshop: Creating a Simple User Control

Exposing Properties Overview

Exposing Methods

Exposing Events

Determining Whether a Control Is Executing in Design-Time or Runtime Mode

Constraining the User Control's Size

Creating Custom Controls

Workshop: Creating the Base of a Custom Control

The Control Structure

Defining the Control's Default Template

Defining the Control's Behavior

Content Controls

Containing a Single Control as Content

Containing Multiple Controls as Content

Attached Properties

Summary

Chapter 13: The Model-View-ViewModel (MVVM) Design Pattern

Benefits of Implementing the MVVM Design Pattern

MVVM Theory

The Layers

Connecting the Layers

Layer Interaction Summary

MVVM in Practice

Creating the Layers

Workshop: Connecting the ViewModel to the View

Communicating Between the View and the ViewModel

MVVM Frameworks

Popular MVVM Frameworks

Should I Use a MVVM Framework?

Creating a Simple MVVM Framework

Implementing Common Scenarios with MVVM

How Do I Assign a Value to a Control's Property?

How Do I Enable/Disable Controls?

How Do I Show/Hide Controls?

How Do I Display a Validation Error in the View?

How Do I Add/Remove Items from a List?

How Do I Select an Item in a List or Get the Currently Selected Item?

How Do I Control the Filtering, Sorting, Grouping, and Paging of Items Displayed in a List?

How Can I Handle Control Events?

How Do I Revert a ViewModel to a Previous State?

How Do I Prevent the User from Doing Anything While an Asynchronous Operation is in Progress?

How Do I Notify the View When an Asynchronous Operation Is Complete?

How Do I Set Focus to a Control?

How Do I Display a Message Box to the User?

How Do I Start a State Transition or Control an Animation?

How Can I Pass Complex Objects Between Views?

How Do I Navigate to a Different View?

How Do I Show a ChildWindow/Dialog?

How Do I Close a ChildWindow?

How Can My ViewModels Communicate with One Another?

How Can I Use My ViewModels at Design Time?

How Can I Use RIA Services in a MVVM-Friendly Manner?

Common MVVM Questions

Should I Implement Dependency Properties or Standard Properties on My ViewModel Class?

Should Model Objects Really Be Exposed Directly to the View?

Should ViewModels Copy Data to and from the Models?

What Should Come First, the View or the ViewModel?

Alternative View / ViewModel Configurations

One ViewModel Serving Multiple Views

One View Interacting with Multiple ViewModels

Summary

Chapter 14: The Managed Extensibility Framework

Terminology

Using MEF

Key Steps in the Composition Process

Managing the Lifetime of Parts

Lazy Imports

Obtaining New Export Instances on Demand

Catalogs

Workshop: Getting Started with MEF

Workshop: Specifying a Contract

Workshop: Importing Multiple Parts

Workshop: Configuring Catalogs and Downloading Modules

Summary

Chapter 15: Printing and Reporting

The Importance of Implementing Reporting

Potential Solutions for Implementing Reporting

Using Silverlight's Printing Functionality

Generating a PDF

Generating HTML

Generating Office Documents

Third-Party Report Viewers

Perpetuum Software's Report Sharp-Shooter for Silverlight

Office Integration Using COM

Choosing a Reporting Strategy

Using Silverlight's Native Printing Functionality

Starting a Print Job

Providing the Content for a Printed Page

Advanced Print Settings

Workshop: Printing a Screen

Workshop: Printing a Report Created in Code

Generating and Displaying a PDF Report

Generating a Report on the Server

Displaying the Report on the Client

The PivotViewer Control

Key Features of the PivotViewer Control

Comparing the Silverlight 4 and Silverlight 5 Versions of the Control

Configuring the PivotViewer Control for Use

Saving and Restoring the PivotViewer Control's State

Uses for the PivotViewer Control

Finding More Information on the PivotViewer Control

Workshop: Implementing the PivotViewer Control

Workshop: Applying an Item Adorner to Trading Cards

Summary

Chapter 16: Interacting with the Host Operating System

Running Silverlight Applications Out of the Browser

Configuring OOB Mode

Installing the Application to Run Out of the Browser

Determining Installation Status

Determining Whether Running Inside or Outside the Browser

Where/How Is the Application's .xap File Stored and Run?

Interacting with the OOB Window

Checking for Updates

Debugging in OOB Mode

Uninstalling the Application

Toast Notifications

Caching Data Locally

Caching to Isolated Storage

Caching to a Client-Side Database

Detecting Network Connection Availability

File System Open and Save Dialogs

The Open File Dialog

The Save File Dialog

Drag-and-Drop Target

Clipboard

Running in Full-Screen Mode

Initiating Full-Screen Mode

Detecting the Switch to and from Full-Screen Mode

Retaining Full-Screen Mode When Unfocused

Keyboard Access

Configuring Elevated Trust

Enabling Elevated Trust in OOB Mode

Enabling Elevated Trust Inside the Browser

Accessing the File System

COM Automation

P/Invoke

Creating Additional OOB Windows

Custom Chrome

Other Restrictions Lifted by Elevated Trust

Restrictions Imposed by Elevated Trust

Enabling/Disabling Elevated Trust Applications with a Windows Group Policy

Summary

Chapter 17: Application Deployment

Deploying the Application to the Server

Server Requirements

Using Xcopy

Workshop: Publishing from Visual Studio

Workshop: Creating a Web Package

Workshop: Creating a Setup Program

Deploying the Application to the Client

The Default Silverlight Installation Process

Customizing the Silverlight Installation Experience

Pushing the Silverlight Runtime to Users in the Enterprise

Building a Client Desktop Installer

Forcing an Update of the Cached XAP File for New Versions

Improving on the Default Application Loading Screen

Workshop: Creating the Application Preloader Files

Workshop: Designing the Application Preloader's Appearance

Workshop: Updating the Application Download Progress

Workshop: Configuring the Preloader in the HTML File

Testing the Application Preloader

Partitioning Your Application

Initial Steps

Assembly Caching

Downloading Modules on Demand

Digitally Signing Your Application

Why Sign Your Application

Obtaining a Code-Signing Certificate

Workshop: Signing Your XAP File

Summary

Index

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset