Microsoft Silverlight 5 Data and Services Cookbook

Over 100 practical recipes for creating rich, data-driven, business applications in Silverlight 5 with this book and ebook

Microsoft Silverlight 5 Data and Services Cookbook

Cookbook
Gill Cleeren, Kevin Dockx

Over 100 practical recipes for creating rich, data-driven, business applications in Silverlight 5 with this book and ebook
$10.00
$59.99
RRP $35.99
RRP $59.99
eBook
Print + eBook
$12.99 p/month

Want this title & more? Subscribe to PacktLib

Enjoy full and instant access to over 2000 books and videos – you’ll find everything you need to stay ahead of the curve and make sure you can always get the job done.
+ Collection
Free sample

Book Details

ISBN 139781849683500
Paperback662 pages

About This Book

  • Design and develop rich data-driven business applications in Silverlight and Windows Phone 7 following best practices using this book and eBook
  • Rapidly interact with services and handle multiple sources of data within Silverlight and Windows Phone 7 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, using data and services using MVVM techniques and much more!
  • Packed with practical, hands-on cookbook recipes, illustrating the techniques to solve particular data problems effectively within your Silverlight and Windows Phone 7 business applications
  • This book is an update to Microsoft Silverlight 4 Data and Services Cookbook

Who This Book Is For

If you are a .NET developer who wants to build professional data-driven applications with Silverlight or Windows Phone 7, then this book is for you. Basic experience of programming Silverlight and familiarity with accessing data using ADO.NET in normal .NET applications is required.

Table of Contents

Chapter 1: Learning the Nuts and Bolts of Silverlight 5
Introduction
Getting our environment ready to start building Silverlight applications
Creating our first service-enabled and data-driven Silverlight 5 application using Visual Studio 2010
Using the workflow between Visual Studio 2010 and Blend 5
Using source control in Visual Studio 2010 and Blend 5
Deploying a Silverlight application on the server
Chapter 2: An Introduction to Data Binding
Introduction
Displaying data in Silverlight applications
Creating dynamic bindings
Binding data to another UI element
Binding collections to UI elements
Enabling a Silverlight application to automatically update its UI
Obtaining data from any UI element it is bound to
Using the different modes of data binding to allow persisting data
Debugging data binding expressions in Visual Studio
Data binding from Expression Blend 5
Using Expression Blend 5 for sample data generation
Chapter 3: Advanced Data Binding
Introduction
Hooking into the data binding process
Replacing converters with Silverlight 5 BindingBase properties
Validating data-bound input
Validating data input using attributes
Validating using IDataErrorInfo and INotifyDataErrorInfo
Using templates to customize the way data is shown by controls
Using implicit data templates
Using the Ancestor RelativeSource binding
Creating custom markup extensions
Building a change-aware collection type
Combining converters, data binding, and DataContext into a custom DataTemplate
Chapter 4: The Data Grid
Introduction
Displaying data in a customized DataGrid
Inserting, updating, and deleting data in a DataGrid
Sorting and grouping data in a DataGrid
Filtering and paging data in a DataGrid
Using custom columns in the DataGrid
Implementing master-detail in the DataGrid
Validating the DataGrid
Chapter 5: Working with Local Data
Introduction
Reading data from and storing data in the isolated storage
Working with IsolatedStorageSettings
Caching data between different Silverlight applications using isolated storage
Using the Sterling database
Chapter 6: MVVM
Introduction
Creating a basic MVVM application
Using MVVM Light to enable MVVM applications
Connecting a View to a ViewModel using a ViewModelLocator
Connecting a View to a ViewModel using MEF
Using commands to pass your events to the ViewModel
Communicating between different ViewModels
Leveraging a messenger to wrap application-wide messages
Chapter 7: Working with Services
Introduction
Connecting and reading from a standardized service
Persisting data using a standardized service
Configuring cross-domain calls
Working cross-domain from a trusted Silverlight application
Reading XML using HttpWebRequest
Reading out an RSS feed
Accessing a database in the cloud
Accessing a service in the cloud
Running a Silverlight application from the cloud
Using socket communication in Silverlight
Chapter 8: Talking to WCF and ASMX Services
Introduction
Invoking a service that exposes data
Invoking a service such as Bing.com
Optimizing performance using binary XML
Debugging a service in Silverlight
Using ASP.NET Authentication in Silverlight
Uploading files to a WCF service
Displaying images as a stream from a WCF service
Chapter 9: Talking to WCF and ASMX Services—One Step Beyond
Introduction
Using duplex communication over HTTP
Using duplex communication with the WCF net.tcp binding
Ensuring data is encrypted
Securing service communication using message-based security
Integrating Windows Identity Foundation in Silverlight
Calling a WCF service from Silverlight using ChannelFactory
Chapter 10: Talking to REST and WCF Data Services
Introduction
Reading data from a REST service
Parsing REST results with LINQ To XML
Persisting data using a REST service
Working with the ClientHttp stack
Communicating with a REST service using JSON
Using WCF Data Services with Silverlight
Reading data using WCF Data Services
Persisting data using WCF Data Services
Talking to Flickr
Talking to Twitter over REST
Passing credentials and cross-domain access to Twitter from a trusted Silverlight application
Chapter 11: Using WCF RIA Services
Introduction
Setting up a data solution to work with WCF RIA Services
Using a WCF RIA Services class library
Getting data on the client
Using LoadBehavior to control what happens to your data once it's sent to the client
Controlling the server-side query from the client
Sorting and filtering data on the server
Paging through your data
Persisting a change set/unit of work
Working with concurrency and transactions
Chapter 12: Advanced WCF RIA Services
Introduction
Tracking a user's identity default Windows authentication
Tracking a user's identity — a custom authentication service
Integrating Windows Identity Foundation with WCF RIA Services
Controlling a user's access to services and service methods
Validating data: using data annotations
Validating data: writing a custom validator
Validating data: server-side validation with client-side feedback
Validating data: triggering validation when needed
Validating data: using the ValidationContext
Handling errors on the server
Using SQL Azure with WCF RIA Services
Exposing WCF RIA Domain Services as OData endpoints
Exposing WCF RIA Domain Services for other technologies
Chapter 13: Windows Phone 7
Introduction
Getting our environment ready to start building Windows Phone 7 applications
Building your first data-driven Windows Phone 7 application
Getting data on your Windows phone 7 using WCF
Accessing REST services from Windows Phone 7 using XML
Accessing REST services from Windows Phone 7 using JSON
Working with push notifications using the cloud
Storing data in a local SQL CE database
Using the background transfer service

What You Will Learn

  • Build and maintain data-driven applications easily using the data binding engine, which does most of the work for you
  • See how validation can be applied effectively to ensure correct input within your applications
  • Use Isolated Storage classes to store data locally, possibly even between sessions, instead of accessing your services for each data need, bringing down the load on your servers
  • Learn all about the Model-View-View-Model (MVVM) pattern and how you can access data and services from an MVVM architecture
  • Access all kinds of services, including WCF, ASMX, REST, RSS, sockets and more from your Silverlight applications, even if hosted in Windows Azure
  • Get a deep knowledge about WCF RIA Services and how you can build your architecture around them
  • Build data-driven Windows Phone 7 applications and leverage your knowledge in the mobile platform
  • Throughout the book, you’ll learn to use XAML & C# to build your LOB applications – skills that can be reused for Windows 8 development

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, both in an out of the browser. It is also the heart of Windows Phone 7 development so developers can leverage their knowledge on Microsoft’s new mobile platform as well. 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, enterprise-ready solutions with the platform. Silverlight 3 and 4 made a big step into Line-Of-Business data services and Silverlight 5 builds further upon this.

In this book, Gill Cleeren, Microsoft Regional Director, Silverlight MVP (former ASP.NET MVP), Telerik MVP at Ordina Belgium and Kevin Dockx, a technical specialist/project leader on .NET web applications and a solution manager for Rich Applications at RealDolmen, focus on showing .NET developers how to get their finger on the pulse of data-driven business applications in Silverlight and Windows Phone 7. What’s more, the upcoming Windows 8 will allow developers to build native, immersive Metro-style applications using XAML & C# - exactly what this book is based upon. In other words, the techniques described in this book also apply to Windows 8.

This book is not a general Silverlight 4/5 overview book; it is uniquely aimed at developers who want to build data-driven applications, based on best practices. 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 features covered work both in Silverlight 4 and 5. However, we cover some that are specific to Silverlight 5, which will therefore not work with Silverlight 4. 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 and 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. This book also covers topics related to storing data locally as well as explaining how to work with data and services in a Model-View-View-Model (MVVM) architecture. Most of the content is applicable to Windows Phone 7 developers as well; a specific chapter on WP7 development is included in this release. 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 applying best practices such as MVVM. Each recipe covers a data services topic, going from the description of the problem, through a conceptual solution to a solution containing sample code.

Authors

Table of Contents

Chapter 1: Learning the Nuts and Bolts of Silverlight 5
Introduction
Getting our environment ready to start building Silverlight applications
Creating our first service-enabled and data-driven Silverlight 5 application using Visual Studio 2010
Using the workflow between Visual Studio 2010 and Blend 5
Using source control in Visual Studio 2010 and Blend 5
Deploying a Silverlight application on the server
Chapter 2: An Introduction to Data Binding
Introduction
Displaying data in Silverlight applications
Creating dynamic bindings
Binding data to another UI element
Binding collections to UI elements
Enabling a Silverlight application to automatically update its UI
Obtaining data from any UI element it is bound to
Using the different modes of data binding to allow persisting data
Debugging data binding expressions in Visual Studio
Data binding from Expression Blend 5
Using Expression Blend 5 for sample data generation
Chapter 3: Advanced Data Binding
Introduction
Hooking into the data binding process
Replacing converters with Silverlight 5 BindingBase properties
Validating data-bound input
Validating data input using attributes
Validating using IDataErrorInfo and INotifyDataErrorInfo
Using templates to customize the way data is shown by controls
Using implicit data templates
Using the Ancestor RelativeSource binding
Creating custom markup extensions
Building a change-aware collection type
Combining converters, data binding, and DataContext into a custom DataTemplate
Chapter 4: The Data Grid
Introduction
Displaying data in a customized DataGrid
Inserting, updating, and deleting data in a DataGrid
Sorting and grouping data in a DataGrid
Filtering and paging data in a DataGrid
Using custom columns in the DataGrid
Implementing master-detail in the DataGrid
Validating the DataGrid
Chapter 5: Working with Local Data
Introduction
Reading data from and storing data in the isolated storage
Working with IsolatedStorageSettings
Caching data between different Silverlight applications using isolated storage
Using the Sterling database
Chapter 6: MVVM
Introduction
Creating a basic MVVM application
Using MVVM Light to enable MVVM applications
Connecting a View to a ViewModel using a ViewModelLocator
Connecting a View to a ViewModel using MEF
Using commands to pass your events to the ViewModel
Communicating between different ViewModels
Leveraging a messenger to wrap application-wide messages
Chapter 7: Working with Services
Introduction
Connecting and reading from a standardized service
Persisting data using a standardized service
Configuring cross-domain calls
Working cross-domain from a trusted Silverlight application
Reading XML using HttpWebRequest
Reading out an RSS feed
Accessing a database in the cloud
Accessing a service in the cloud
Running a Silverlight application from the cloud
Using socket communication in Silverlight
Chapter 8: Talking to WCF and ASMX Services
Introduction
Invoking a service that exposes data
Invoking a service such as Bing.com
Optimizing performance using binary XML
Debugging a service in Silverlight
Using ASP.NET Authentication in Silverlight
Uploading files to a WCF service
Displaying images as a stream from a WCF service
Chapter 9: Talking to WCF and ASMX Services—One Step Beyond
Introduction
Using duplex communication over HTTP
Using duplex communication with the WCF net.tcp binding
Ensuring data is encrypted
Securing service communication using message-based security
Integrating Windows Identity Foundation in Silverlight
Calling a WCF service from Silverlight using ChannelFactory
Chapter 10: Talking to REST and WCF Data Services
Introduction
Reading data from a REST service
Parsing REST results with LINQ To XML
Persisting data using a REST service
Working with the ClientHttp stack
Communicating with a REST service using JSON
Using WCF Data Services with Silverlight
Reading data using WCF Data Services
Persisting data using WCF Data Services
Talking to Flickr
Talking to Twitter over REST
Passing credentials and cross-domain access to Twitter from a trusted Silverlight application
Chapter 11: Using WCF RIA Services
Introduction
Setting up a data solution to work with WCF RIA Services
Using a WCF RIA Services class library
Getting data on the client
Using LoadBehavior to control what happens to your data once it's sent to the client
Controlling the server-side query from the client
Sorting and filtering data on the server
Paging through your data
Persisting a change set/unit of work
Working with concurrency and transactions
Chapter 12: Advanced WCF RIA Services
Introduction
Tracking a user's identity default Windows authentication
Tracking a user's identity — a custom authentication service
Integrating Windows Identity Foundation with WCF RIA Services
Controlling a user's access to services and service methods
Validating data: using data annotations
Validating data: writing a custom validator
Validating data: server-side validation with client-side feedback
Validating data: triggering validation when needed
Validating data: using the ValidationContext
Handling errors on the server
Using SQL Azure with WCF RIA Services
Exposing WCF RIA Domain Services as OData endpoints
Exposing WCF RIA Domain Services for other technologies
Chapter 13: Windows Phone 7
Introduction
Getting our environment ready to start building Windows Phone 7 applications
Building your first data-driven Windows Phone 7 application
Getting data on your Windows phone 7 using WCF
Accessing REST services from Windows Phone 7 using XML
Accessing REST services from Windows Phone 7 using JSON
Working with push notifications using the cloud
Storing data in a local SQL CE database
Using the background transfer service

Book Details

ISBN 139781849683500
Paperback662 pages
Read More

Recommended for You