1 Introduction to Silverlight
Total Page:16
File Type:pdf, Size:1020Kb
1 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-plat- form 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 COPYRIGHTEDapplication and run it in a Safari MATERIALweb 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 chap- ter 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. 650929c01.indd 1 7/5/10 6:48:16 AM 2 ❘ CHAPTER 1 INTRODUCTION TO SILVERLIGHT 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 applica- tions 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 graph- ics, 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 applica- tion model when building Silverlight applications. 650929c01.indd 2 7/5/10 6:48:16 AM What Is Silverlight? ❘ 3 ➤➤ 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 design- ing 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. For a good comparison of what is in WPF and not in Silverlight 4, check out this link: http://msdn.microsoft.com/en-us/library/cc903925(VS.96).aspx 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. 650929c01.indd 3 7/5/10 6:48:16 AM 4 ❘ CHAPTER 1 INTRODUCTION TO SILVERLIGHT 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. .NET for SIlverlight MS AJAX Library Data WPF WCF LINQ Controls REST POX XLINQ Data Binding RSS/ATOM JSON XML Layout SOAP Editing JavaScript DLR BCL Engine Iron Python Generics Iron Ruby Collections Jscript Cryptography Threading CLR Execution Engine XAML UI Core Inputs DRM Vector Text Keyboard Media Animation Images Mouse Ink Media Deep Zoom VC1 Images H.264 WMA AAC MP3 Presentation Core Browser Host Integrated DOM Application Installer Networking Stack Integration Services FIGURE 1-1 TABLE 1-1 OPERATING SYSTEM BRowSER SUPPORTED Windows Vista Windows Internet Explorer 7, 8 Windows Server 2008 Firefox 2, 3 Google Chrome 650929c01.indd 4 7/5/10 6:48:16 AM Silverlight Versions Explained ❘ 5 OPERATING SYSTEM BRowSER SUPPORTED Windows 7 Windows Internet Explorer 8 Firefox 2, 3 Google Chrome Windows Server 2008 R2 Windows Internet Explorer 8 Google Chrome Windows XP SP2, SP3 Windows Internet Explorer 6, 7, 8 Firefox 2, 3 Google Chrome Windows Server 2003 Windows Internet Explorer 6, 7, 8 (excluding IA-64) Firefox 2, 3 Google Chrome Mac OS 10.4.8+ Firefox 2, 3 Safari 3 Safari 4 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 applica- tions 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.