Silverlight 4 Data and Services Cookbook

Book description

Over 80 practical recipes for creating rich, data-driven business applications in Silverlight

  • Design and develop rich data-driven business applications in Silverlight
  • Rapidly interact with and handle multiple sources of data and services within Silverlight business applications
  • Understand sophisticated data access techniques in your Silverlight business applications by binding data to Silverlight controls, validating data in Silverlight, getting data from services into Silverlight applications and much more!
  • Packed with practical, hands-on cookbook recipes, illustrating the techniques to solve particular data problems effectively within your Silverlight business applications

In Detail

Microsoft Silverlight is a programmable web browser plugin that enables features including animation, vector graphics, and audio-video playback – features that characterize Rich Internet Applications. However, Silverlight is a great (and growing) Line-Of-Business platform and is increasingly being used to build data-driven business applications. Silverlight Data Services enable efficient access to your data, allowing you to draw on multiple sources of data and solve particular data problems. There is very little existing material that demonstrates how to build data-driven solutions with the platform. Silverlight 3 made a big step into Line-Of-Business data services and Silverlight 4 builds further upon this. This book will enable .NET developers to get their finger on the pulse of data-driven business applications in Silverlight.

This book is not a general Silverlight 3/4 overview book; it is uniquely aimed at developers who want to build data-driven applications. It focuses on showing .NET developers how to interact with, and handle multiple sources of data in Silverlight business applications, and how to solve particular data problems following a practical hands-on approach, using real-world recipes. It is a practical cookbook that teaches you how to build data-rich business applications with Silverlight that draw on multiple sources of data. Most of the covered features work both in Silverlight 3 and 4. However, we cover some that are specific for Silverlight 4, which will therefore not work with Silverlight 3. Where this is the case, it is clearly indicated.

Packed with reusable, real-world recipes, the book begins by introducing you to general principles when programming Silverlight. It then dives deep into the world of data services, covering all the options available to access data and communicate with services to get the most out of data in your Silverlight business applications, whilst at the same time providing a rich user experience. Chapters cover data binding, data controls, the concepts of talking to services, communicating with WCF, ASMX and REST services, and much more.

By following the practical recipes in this book, which are of varying difficulty levels, you will learn the concepts needed to create data-rich business applications—from the creation of a Silverlight application, to displaying data in the Silverlight application and upgrading your existing applications to use Silverlight. Each recipe covers a data services topic, going from the description of the problem, through a conceptual solution to a solution containing sample code.

Build smart data-driaven business applications with Silverlight

Table of contents

  1. Silverlight 4 Data and Services Cookbook
    1. Table of Contents
    2. Silverlight 4 Data and Services Cookbook
    3. Credits
    4. About the authors
    5. About the reviewers
    6. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code for the book
        2. Errata
        3. Piracy
        4. Questions
    7. 1. Learning the Nuts and Bolts of Silverlight 4
      1. Introduction
      2. Getting our environment ready to start developing Silverlight applications
        1. How to do it...
        2. How it works...
        3. See also
      3. Creating our first service-enabled and data-driven Silverlight 4 application using Visual Studio 2010
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. The solution and project structure
            1. Services
            2. Data binding
        4. See also
      4. Using the workflow between Visual Studio 2010 and Blend 4
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Using source control in Visual Studio 2010 and Blend 4
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. Commonly used terms in TFS
      6. Deploying a Silverlight application on the server
        1. How to do it...
        2. How it works...
          1. Configuration changes on the server
          2. What if the server doesn't allow using XAP?
    8. 2. An Introduction to Data Binding
      1. Introduction
      2. Displaying data in Silverlight applications
        1. Getting ready
        2. How to do it...
          1. How it works...
          2. There's more...
          3. See also
      3. Creating dynamic bindings
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      4. Binding data to another UI element
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Element bindings without bindings
        5. See also
      5. Binding collections to UI elements
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Enabling a Silverlight application to automatically update its UI
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. Single objects
          2. Collections
          3. Cleaning up the code
      7. Obtaining data from any UI element it is bound to
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Using the different modes of data binding to allow persisting data
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Data binding from Expression Blend 4
        1. How to do it...
        2. How it works...
      10. Using Expression Blend 4 for sample data generation
        1. How to do it...
    9. 3. Advanced Data Binding
      1. Introduction
      2. Hooking into the data binding process
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. The ConvertParameter
          2. Displaying images based on a URL with converters
      3. Replacing converters with Silverlight 4 BindingBase properties
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Validating databound input
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Validating data input using attributes
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. Other uses of data annotations
        6. See also
      6. Validating using IDataErrorInfo and INotifyDataErrorInfo
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      7. Using templates to customize the way data is shown by controls
        1. Getting ready
        2. How to do it...
          1. How it works...
      8. Building a change-aware collection type
        1. Getting ready
        2. How to do it...
          1. How it works...
          2. See also
      9. Combining converters, data binding, and DataContext into a custom DataTemplate
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    10. 4. The Data Grid
      1. Introduction
      2. Displaying data in a customized DataGrid
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more
        5. See also
      3. Inserting, updating, and deleting data in a DataGrid
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Sorting and grouping data in a DataGrid
        1. Getting ready
        2. How to do it...
          1. How it works...
          2. There's more...
            1. Sorting a template column
          3. See also
      5. Filtering and paging data in a DataGrid
        1. Getting ready
        2. How to do it...
          1. How it works...
          2. There's more...
          3. See also
      6. Using custom columns in the DataGrid
        1. Getting ready
        2. How to do it...
          1. How it works...
          2. There's more...
      7. Implementing master-detail in the DataGrid
        1. Getting ready
        2. How to do it...
          1. How it works...
          2. There's more...
      8. Validating the DataGrid
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. RIA Services and data annotations
        5. See also
    11. 5. The DataForm
      1. Introduction
      2. Displaying and editing an object using the DataForm
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. More on DataForm behavior
          2. Validating a DataForm or a DataGrid
          3. Managing the editing of an object on different levels
        5. See also
      3. Displaying and editing a collection using the DataForm
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Customizing the DataForm using Data Annotations
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Using Data Annotations for validation
        5. See also
      5. Customizing the DataForm using a custom DataTemplate
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Customizing the DataForm template
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Getting the default template of a control
        5. See also
      7. Validating the DataForm
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Other uses of Data Annotations
            1. RIA Services and Data Annotations
        5. See also
    12. 6. Talking to Services
      1. Introduction
      2. Connecting and reading from a standardized service
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      3. Persisting data using a standardized service
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Configuring cross-domain calls
        1. Getting ready
        2. How to do it...
          1. How it works...
      5. Working cross-domain from a trusted Silverlight application
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Reading XML using HttpWebRequest
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. The request
          2. The response
          3. Threading headaches
        4. See also
      7. Reading out an RSS feed
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. RSS versions
        5. See also
      8. Aggregating RSS feeds
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Talking with services in the Windows Azure cloud
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. What about other cloudservices?
        5. See also
      10. Persisting data to and reading data from the Windows Azure cloud
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. What about relational data storage?
        5. See also
      11. Using socket communication in Silverlight
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. The policy server
          2. The socket server
          3. Connecting the Silverlight application
    13. 7. Talking to WCF and ASMX Services
      1. Introduction
      2. Invoking a service that exposes data
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. The WCF service
            1. Connecting to the service
        4. See also
      3. Invoking a service such as Bing.com
        1. Getting ready
        2. How to do it...
          1. How it works...
          2. There's more...
          3. See also
      4. Handling faults when calling a service
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      5. Optimizing performance using binary XML
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. The default configuration is different depending on the version of Silverlight you're using
          2. Using binary encoding is not a security measure
        4. See also
      6. Using duplex communication
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. The PollingDuplexBinding: polling, binding, and assemblies
          2. The service
          3. The client
        4. See also
      7. Using duplex communication with the WCF net.tcp binding
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. Setup requirements
        4. See also
      8. Debugging a service in Silverlight
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. Types of faults
            1. Declared faults
            2. Undeclared faults
      9. Ensuring data is encrypted
        1. Getting ready...
        2. How to do it...
        3. How it works...
        4. See also
      10. Securing service communication using message-based security
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. Transport security is required
        4. See also
      11. Uploading files to a WCF service
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      12. Displaying images as a stream from a WCF service
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      13. Hooking into proxy creation using slsvcutil.exe
        1. Getting ready
        2. How to do it...
        3. How it works...
      14. Calling a WCF service from Silverlight using ChannelFactory
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    14. 8. Talking to REST and WCF Data Services
      1. Introduction
      2. Reading data from a REST service
        1. Getting ready
        2. How to do it...
          1. How it works...
          2. See also
      3. Parsing REST results with LINQ-To-XML
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      4. Persisting data using a REST service
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      5. Working with the ClientHttpStack
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. Advantages of ClientHttpStack
        4. See also
      6. Communicating with a REST service using JSON
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Using WCF Data Services with Silverlight
        1. Getting ready
        2. How to do it...
        3. How it works...
          1. Locked-down services
        4. See also
      8. Reading data using WCF Data Services
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Persisting data using WCF Data Services
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      10. Talking to Flickr
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. Flickr... more information
        5. See also
      11. Talking to Twitter over REST
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      12. Passing credentials and cross-domain access to Twitter from a trusted Silverlight application
        1. Getting ready
        2. How to do it...
        3. How it works...
            1. Let's go cross-domain!
            2. Pass me those credentials, will you?
        4. See also
    15. 9. Talking to WCF RIA Services
      1. Introduction
      2. Setting up a data solution to work with RIA Services
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. The WCF RIA Services Toolkit
        5. See also
      3. Getting data on the client
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      4. Sorting and filtering data
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      5. Persisting data to the server
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      6. Persisting a Unit of Work/changeset
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      7. Working with concurrency and transactions
        1. Getting ready
        2. How to do it...
        3. How it works...
      8. Tracking a user's identity
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      9. Controlling a user's access to a service and service methods
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
      10. Validating data using data annotations
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      11. Validating data using shared code
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      12. Using the DomainDataSource
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
        5. See also
      13. Using the DomainDataSource to page through data
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      14. Sorting, filtering, and grouping data using the DomainDataSource
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
    16. 10. Converting Your Existing Applications to Use Silverlight
      1. Introduction
      2. Calling a stored procedure from Silverlight
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      3. Working with LINQ to SQL from Silverlight
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. What is LINQ TO SQL?
        5. See also
      4. Working with the Entity Framework from Silverlight
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. There's more...
          1. What is the Entity Framework?
        5. See also
      5. Converting a Silverlight application to use WCF RIA Services
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      6. Using ASP.NET Authentication in Silverlight
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      7. Using ASP.NET Roles in Silverlight
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
      8. Using ASP.NET Profiles in Silverlight
        1. Getting ready
        2. How to do it...
        3. How it works...
        4. See also
    17. A. Appendix
      1. Creating a REST service from WCF
      2. Installing a SQL Server database
        1. Attaching an MDF file
        2. Executing a query file
      3. Working with Fiddler
        1. Local traffic
      4. Working with the Silverlight control toolkit
    18. Index

Product information

  • Title: Silverlight 4 Data and Services Cookbook
  • Author(s): Gill Cleeren, Kevin Dockx
  • Release date: April 2010
  • Publisher(s): Packt Publishing
  • ISBN: 9781847199843