Professional Silverlight 4

Professional Silverlight 4

4.5 2
by Jason Beres, Bill Evjen, Devin Rader
     
 

Exploit the powerful capabilities of the new Silverlight 4

The Silverlight 4 platform continues to add excitement to building rich Internet applications (RIAs), and it offers new user interface controls, expanded capabilities of the Base Class Libraries, and new libraries for building Line of Business applications. This invaluable resource helps you take your

See more details below

Overview

Exploit the powerful capabilities of the new Silverlight 4

The Silverlight 4 platform continues to add excitement to building rich Internet applications (RIAs), and it offers new user interface controls, expanded capabilities of the Base Class Libraries, and new libraries for building Line of Business applications. This invaluable resource helps you take your existing development skills to the next level so that you can create compelling RIAs with the new Silverlight 4. The trio of veteran authors presents clear and concise coverage of Silverlight essentials and its platforms concepts, while real-world samples enhance your learning process so you can get started building and running RIAs right away.

Professional Silverlight 4:

  • Explains how to build Silverlight applications with Expression Blend 4 and Visual Studio 2010
  • Reviews the Navigation Framework, visual controls, and working with networking in your applications
  • Delves into graphics, animations, text, media, theming, and styling
  • Details techniques for testing Silverlight 4 applications
  • Explores methods for building Facebook applications with Silverlight

Wrox Professional guides are planned and written by working programmers to meet the real-world needs of programmers, developers, and IT professionals. Focused and relevant, they address the issues technology professionals face every day. They provide examples, practical solutions, and expert education in new technologies, all designed to help programmers do a better job.

wrox.com

Programmer Forums
Join our Programmer to Programmer forums to ask and answer programming questions about this book, join discussions on the hottest topics in the industry, and connect with fellow programmers from around the world.

Code Downloads
Take advantage of free code samples from this book, as well as code samples from hundreds of other books, all ready to use.

Read More
Find articles, ebooks, sample chapters, and tables of contents for hundreds of books, and more reference resources on programming topics that matter to you.

Read More

Product Details

ISBN-13:
9780470650929
Publisher:
Wiley
Publication date:
08/09/2010
Pages:
840
Product dimensions:
9.50(w) x 11.06(h) x 1.62(d)

Related Subjects

Read an Excerpt

Professional Silverlight 4


By Jason Beres Bill Evjen Devin Rader

John Wiley & Sons

Copyright © 2010 John Wiley & Sons, Ltd
All right reserved.

ISBN: 978-0-470-65092-9


Chapter One

Introduction to Silverlight

What's in this Chapter?

* Overviewing Silverlight * Getting the Silverlight Plug-In and SDK * Taking a Silverlight 4 Tour

Silverlight 4, the fourth iteration of the Silverlight platform, continues to deliver on the promise of Adobe Flash–like and Flex-like rich Internet applications (RIAs) built using a standards-based, open approach with HTML and XAML (eXtensible Application Markup Language) using tools like Visual Studio 2010 and Microsoft Expression Blend. Silverlight 4 continues to add excitement to RIA development with the expansion of the capabilities of the Base Class Libraries (BCLs) from the .NET Framework, new user interface (UI) controls, and new libraries for building line-of-business applications. The result is that not only do you have the rich, XAML markup to describe expressive user interfaces, you have the power of the .NET Framework and your language of choice (C#, VB, etc.) to build Silverlight applications. Even with the .NET Framework libraries, Silverlight still retains the cross-browser and cross-platform compatibility that it has had since the beginning. This includes Windows 2000, Windows XP, Windows Vista, Windows 7, Macintosh, and, through the Mono Project, various Linux distributions. To give you an idea of the flexibility of the client and server scenarios, you can build a Silverlight application and run it in a Safari web browser on an Apple Macintosh, while being served up from an Apache web server running on Linux.

There is a lot to learn about Silverlight, and you'll gain more and more insight with each chapter in this book.

This chapter does two basic things:

* It gives you an introduction to Silverlight.

* By covering the essentials on creating Silverlight applications, it sets the groundwork that helps for the rest of the book.

WHAT IS SILVERLIGHT?

Silverlight is a web-based platform for building and running RIAs. The web-based platform part of that equation is essentially the plug-in that runs inside the web browser. Silverlight applications execute within an ActiveX browser plug-in that installs onto the local machine via the web browser in the exact same manner that you install Adobe Flash to run Flash-based animations on web pages. The Silverlight plug-in supports the entire wow factor that you'd expect from an RIA, such as vector-based graphics and animations and full video integration, including Digital Rights Management (DRM) secured audio/video and high-definition video, as well as the tools for building rich line-of-business applications. You can boil down the coolness of Silverlight to the following points:

* Silverlight is a cross-platform, cross-browser platform for delivering rich, interactive applications. * Silverlight 4 applications can be built using Expression Blend, Visual Studio, or Eclipse on Windows, and with Eclipse on Apple Macintosh computers. * Silverlight supports playback of native Windows Media VC-1/WMA (with Digital Rights Management) as well as MPEG-4-based H.264 and AAC audio on PCs and Macs with no dependency on Windows Media Player, as well as full online and offline DRM capability for purchase and download, rental, and subscription capabilities. * Silverlight supports playback of 720p+ full-screen HD Video. * Using XAML, HTML, JavaScript, C#, or VB (or your managed language of choice, including dynamic languages like Ruby and Python), Silverlight delivers rich multimedia, vector graphics, animations, and interactivity beyond what AJAX can deliver. * With the Base Class Libraries, you have access to common classes for generics, collections, and threading that you are accustomed to using in Windows client development. * There are more than 60 controls in the Toolbox, and probably five times that many from third-party vendors. * You can deliver out-of-browser experiences with elevated trust that can run any Silverlight 4 application just like a desktop application; including network access, COM interoperability, and local filesystem access. * You can access video and audio resources, giving you the ability to record content that is streaming from an end user's local computer. * There are multiple lines of business features, including a navigation framework, printing, drag-and-drop support, clipboard access, right-click events, and multi-directional text rendering. * RIA Services, or the Business Application template, supply the framework, tools, and services that provide the server context of your application to the client, which simplifies the application model when building Silverlight applications. * The installation package is less than 6MB on Windows and less than 12MB on Macintosh. * Almost all of the same XAML and application logic created for Silverlight applications can be used in Windows Presentation Foundation (WPF) applications with no changes.

The Silverlight player is also known as a plug-in, or control — these terms are used interchangeably in the book, and you will see these variances when others talk about Silverlight as well. The player is a completely stand-alone environment; there is no dependency version of the .NET Framework on the client or the server to run Silverlight applications. When developing applications for Silverlight, you use tools (like Visual Studio 2010 or Expression Blend) that require or are based on a version of the Common Language Runtime (CLR), but the compiled Intermediate Language (IL) of your Silverlight applications that is parsed by the Silverlight player is not using a specific client version of the .NET Framework. The BCL for Silverlight is entirely self-contained within the player itself. The XAML and BCL used by the Silverlight player are both subsets of their counterparts that are used when building full desktop-based WPF applications. In Silverlight 4, the features in Silverlight and the CLR 4 version of WPF are coming closer together, which gives you more flexibility when designing applications that you intend to target both run times.

You might ask why Microsoft is pushing out another web-based, client-side technology when there is already ASP.NET, ASP.NET AJAX Extensions, and, with CLR 4 and Visual Studio 2010, specific project types that target Dynamic Data, MVC, and the ASP.NET AJAX Framework. The simple answer is that users are demanding an even richer experience on the Web. Even though AJAX does a lot for improved user experience — the postback nightmare of Web 1.0 is finally going away — it does not do enough. There is demand for a richer, more immersive experience on the Web. This has been accomplished with WPF on the Windows client side. WPF provides a unified approach to media, documents, and graphics in a single run time. The problem with WPF is that it is a 30-MB run time that runs only on the Windows OS. Microsoft needed to give the same type of experience that WPF offers, only in a cross-platform, cross-browser delivery mechanism. So what Microsoft did was take the concept of a plug-in model like Adobe Flash and mix it with the .NET Framework and the WPF declarative language in XAML, and they came up with a way to develop highly rich, immersive Web 2.0 applications.

The big picture of Silverlight from an architecture perspective is shown in Figure 1-1. Each area is covered in more detail as you read along in the book.

As mentioned earlier, Silverlight can conceivably be fully supported across multiple browsers and operating systems. The current status for browser and OS support is identified in Table 1-1.

SILVERLIGHT VERSIONS EXPLAINED

If you have been following Silverlight, you might be a little confused over the versions that are available:

* Silverlight 1.0 — Released in September of 2007, this is the first version of Silverlight and supports the JavaScript programming model. This means that your language choice is simple: JavaScript. JavaScript is used to interact with Silverlight objects that are executing within the Silverlight player in the browser. There is no managed language support in Silverlight 1.0, which means no BCL for Silverlight 1.0. * Silverlight 2 — Released in late 2008, Silverlight 2 brought the ability to create RIA applications with the familiar code-behind programming model used in Windows Forms, ASP.NET, and WPF development. Starting with Silverlight 2, you can use any CLR language to code Silverlight applications, and you have the power of the .NET Framework to interact with Silverlight objects. The ability to use the base class libraries and your .NET language of choice to build Silverlight applications truly revolutionized the way developers and designers looked at this new RIA platform. * Silverlight 3 — Released in mid-2009, Silverlight 3 included extensive enhancements to Silverlight 2 for building line-of-business applications as well as richer support for graphics and media.

* Silverlight 4 — Released in April of 2010, Silverlight 4 continues with the focus on line-of-business–focused applications, and a more feature-complete RIA Services implementation is included, as well as a richer feature set for accessing local filesystem and COM resources in richer, out-of-browser experiences.

Silverlight uses an auto-update model for the player. When a new version of Silverlight is released, the player running in the browser is updated to the latest version automatically. There is also the commitment of backward compatibility, so your applications will not break when the player moves from version 1.0 to 2, or 2 to 3, and so on.

APPLICATION DEVELOPMENT SCENARIOS

When building Silverlight applications, you are likely to use one of the following scenarios:

* Your entire application is written in Silverlight, the player takes up 100 percent of the height and width of the browser, and all UI interaction is done through Silverlight. * You implement an "Islands of Richness" scenario, in which your application is an ASP.NET application (or any other type of HTML-rendered application), and you build islands of your UI with Silverlight. Thus, you add richness to your web applications but you don't build the entire interaction using Silverlight. * You create an out-of-browser (OOB) experience, with the specific need to use elevated permissions on the client machine. This means that you create more of a desktop-like experience and you can access the local filesystem, use COM interoperability, keyboard in full screen mode, and other out-of-browseronly features. * You are building a mobile application that is targeting the Windows 7 Series Phone.

As the adoption of Silverlight grows, the type of application you decide to build most likely depends on the features you need. If you are slowly introducing Silverlight into your applications, the "Islands of Richness" scenario will be used. If you are going all out and need to access the My Documents folder of the client machine, you'll end up building an OOB application.

The area surrounded with the box in Figure 1-2 is an example of an "Islands of Richness" scenario in which Silverlight has been added to an existing web application. In this case, the image strip is a Silverlight control that plays a video in-page when an item is clicked. Silverlight enhances the "Islands of Richness" scenarios by allowing multiple Silverlight plug-ins and an easy way to communicate with each other in the browser. This also works across browsers; for example, a Silverlight application running in a Firefox browser can talk to a Silverlight application running in Internet Explorer 8 on the same machine.

Figure 1-3 shows an OOB experience. Notice that there is no chrome around the browser shell, giving the application a desktop-like experience.

Figure 1-4 shows a typical Silverlight application that takes up 100 percent of the viewable browser area, but is not running outside of the browser.

GETTING THE SILVERLIGHT PLUG-IN

The first time you navigate to a web page that contains a Silverlight application, the Silverlight player is not installed automatically; installation is similar to the Adobe Flash experience. There is a non-intrusive image on the page where the Silverlight content would have rendered that gives a link to download the player. Silverlight has two different prompts for installation — the standard install and the in-place install.

In a standard install, the Get Microsoft Silverlight image tells you that you need to install Silverlight to complete the experience on the web page you have arrived at. Figure 1-5 illustrates a page with the standard install images.

Once you click on the Get Microsoft Silverlight Installation image, one of two scenarios takes place. You are taken to the Silverlight Installation page on the Microsoft site (see Figure 1-6).

Or you are prompted to install Silverlight in-place with a download prompt, as shown in Figure 1-7. After the Silverlight player is installed, you never have to install it again. Silverlight also has built-in knowledge of updates, so once a new version of Silverlight is available, you are asked if you would like to install the update to get the latest version of the player. Once you refresh the browser, the Silverlight content is rendered correctly in the browser (see Figure 1-8).

GETTING THE SILVERLIGHT SDK

To build Silverlight applications, you need more than the Silverlight player. If you have not arrived at a page where you are prompted to install the Silverlight run time, you can easily get it on the Silverlight SDK page. There are also supporting files, help files, samples, and quick starts in the Silverlight Software Development Kit (SDK), which will give you the files you need to start building Silverlight applications. To get the SDK, go to www.silverlight.net/getstarted/ default.aspx, as shown in Figure 1-9.

On the Get Started page, you can download all of the tools that you need to create Silverlight 4 applications:

* Silverlight run times for Mac and Windows operating systems * Silverlight tools for Visual Studio 2010 * The latest version of Microsoft Expression Blend * A trial version of Visual Studio 2010

More importantly, this page has links to dozens of videos, tutorials, and samples that will help you learn Silverlight.

BUILDING SILVERLIGHT APPLICATIONS

Now that you have the Silverlight player installed and you know how to get the tools for Visual Studio that will give you the project templates, you can start building Silverlight applications. There are several ways to create Silverlight applications:

* Visual Studio 2010 Silverlight Project Templates — These include Silverlight Application, Silverlight Navigation Application, and Silverlight Class Library, as well as Silverlight Business Application.

* Expression Blend 3 or Expression Blend 4 — This a tool in the Expression suite of products from Microsoft that provides project templates for creating Silverlight and WPF projects and helps create vector-based graphics for your Silverlight user interface as well as aids in screen prototyping with the Sketch Flow feature. * Eclipse using the Eclipse Plug-In — There is an Eclipse plug-in for both Windows-based and Apple Macintoshbased operating systems.

In the following chapters, you will get a better understanding of the details for how to build applications using Visual Studio 2010 and Expression Blend.

SILVERLIGHT 4 TOUR

Silverlight 4 continues the improvements that Silverlight 3 delivered over Silverlight 2. In the next sections, we'll look at some of the more important features of Silverlight 4, including:

* XAML

*.NET Framework support

* Graphics and animations

* Page layout and design

* User interface controls

* Audio and video, including capturing audio and video

* Local data storage

* Out-of-browser capability

* Local filesystem access

* Navigation Framework

* Ink support

* Network access

* Data binding

* Printing

* Drag-and-drop

* Clipboard access

* Deep Zoom technology

Throughout the book, you learn about each of the items listed in much more detail. The following sections are designed to set the stage for what's to come as you explore the full capability of Silverlight 4.

(Continues...)



Excerpted from Professional Silverlight 4 by Jason Beres Bill Evjen Devin Rader Copyright © 2010 by John Wiley & Sons, Ltd. Excerpted by permission of John Wiley & Sons. All rights reserved. No part of this excerpt may be reproduced or reprinted without permission in writing from the publisher.
Excerpts are provided by Dial-A-Book Inc. solely for the personal use of visitors to this web site.

Read More

Customer Reviews

Average Review:

Write a Review

and post it to your social network

     

Most Helpful Customer Reviews

See all customer reviews >