Read an Excerpt
Professional Silverlight 4
By Jason Beres Bill Evjen Devin Rader
John Wiley & SonsCopyright © 2010 John Wiley & Sons, Ltd
All right reserved.
Chapter OneIntroduction 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:
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 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:
*.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
* 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.
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.