Showing posts with label Silverlight. Show all posts
Showing posts with label Silverlight. Show all posts

Silverlight and Visual Studio

Although it’s technically possible to create the files you need for a Silverlight application by hand, professional developers always use a development tool. If you’re a graphic designer, that tool is likely to be Microsoft Expression Blend 2.5, a graphically rich design package. If you’re a developer, you’ll probably start with Visual Studio 2008 instead. Because both tools are equally at home with the Silverlight 2.0 application model, you can easily create a workflow that incorporates both of them. For example, a developer could create a basic user interface with Visual Studio and then hand it off to a crack design team, which would then polish it up with custom graphics in Expression Blend. When the facelift is finished, they’d deliver the project back to the developer, who could then continue writing and refining code in Visual Studio.

There are two types of Silverlight web sites that you can create in Visual Studio:

Ordinary HTML web site: In this case, the entry point to your Silverlight application is a basic HTML file that includes a Silverlight content region.

ASP.NET web site: In this case, Visual Studio creates two projects—one to contain the Silverlight application files, and one to hold the server-side ASP.NET web site that will be deployed alongside your Silverlight files. The entry point to your Silverlight application can be an ordinary HTML file or an ASP.NET web form that also includes server-generated content.

No matter which option you choose, your Silverlight application will run the same way—the client browser will receive an HTML web page, that HTML page will include a Silverlight content region, and the Silverlight code will run on the local computer, not the web server. However, the ASP.NET web approach makes it easier to mix ASP.NET and Silverlight content. This is usually a better approach in the following cases:

i) You want to create a web application that combines ASP.NET web pages

with Silverlight-enhanced pages.

ii) You want to generate Silverlight content indirectly, using ASP.NET web controls.

iii) You want to create a Silverlight application that calls a web service, and you want to design the web service at the same time (and deploy it to the same web server).

If you decide to create an ASP.NET web site, your application’s requirements will change. Silverlight content can be served by any web server, because it’s sent directly to the web browser and processed on the client side. ASP.NET content runs on the web server, which must have the ASP.NET engine installed.


Source of Information : Apress Silverlight 2 Visual Essentials

Silverlight and WPF

One of the most interesting aspects of Silverlight is the fact that it borrows the model WPF uses for rich, client-side user interfaces. WPF is a next-generation technology for creating Windows applications. It was introduced in .NET 3.0 as the successor to Windows Forms. WPF is notable because it not only simplifies development with a powerful set of high-level features, but also increases performance by rendering everything through the DirectX pipeline. To learn about WPF, you can refer to another of my books, Pro WPF in C# 2008: Windows Presentation Foundation with .NET 3.5, Second Edition (Apress, 2008).

Silverlight obviously can’t duplicate the features of WPF, because many of them rely deeply on the capabilities of the operating system, including Windows-specific display drivers and DirectX technology. However, rather than invent an entirely new set of controls and classes for client-side development, Silverlight uses a subset of the WPF model. If you’ve had any experience with WPF, you’ll be surprised to see how closely Silverlight resembles its bigger brother. Here are a few common details:

To define a Silverlight user interface (the collection of elements that makes up a Silverlight content region), you use XAML markup, just as you do with WPF. You can even map data to your display using the same data binding syntax.

Silverlight borrows many of the same basic controls from WPF, along with the same styling system (for standardizing and reusing formatting) and a similar templating mechanism (for changing the appearance of standard controls).

To draw 2D graphics in Silverlight, you use shapes, paths, transforms, geometries, and brushes, all of which closely match their WPF equivalents.

Silverlight provides a declarative animation model that’s based on storyboards and works in the same way as WPF’s animation system.

To show video or play audio files, you use the MediaElement class, as you do in WPF. capabilities of Silverlight by drawing from the full WPF model. In future Silverlight releases, you’re likely to find that Silverlight borrows more and more features from WPF. This trend is already on display with the shift from Silverlight 1.0 to Silverlight 2.0.

In other words, Silverlight is a .NET-based Flash competitor. It aims to compete with Flash today, but provide a path to far more features in the future. Unlike the Flash development model, which is limited in several ways due to the way it’s evolved over the years, Silverlight is a startingfrom-scratch attempt that’s thoroughly based on .NET and WPF, and will therefore allow .NET developers to be far more productive. In many ways, Silverlight is the culmination of two trends: the drive to extend web pages to incorporate more and more rich-client features, and the drive to give the .NET Framework a broader reach.

Silverlight 1.0 and 2.0

Silverlight exists in two versions:

The first version, Silverlight 1.0, is a relatively modest technology. It includes the 2D drawing features and the media playback features. However, it doesn’t include the CLR engine or support for .NET languages, so any code you write must use JavaScript.

The second version, Silverlight 2.0, adds the .NET-powered features that have generated the most developer excitement. It includes the CLR, a subset of .NET Framework classes, and a user interface model based on WPF (as described in the next section, “Silverlight and WPF”). Many developers consider Silverlight 2.0 to be the real first release of theSilverlight platform.

At present, Silverlight is only on a fraction of computers. However, Microsoft is convinced that if compelling content exists for Silverlight, users will download the plug-in. A number of factors support this argument. Flash grew dramatically in a short space of time, and Microsoft has obvious experience with other web-based applications that have started small and eventually gained wide adoption. (Windows Messenger comes to mind, along with numerous ActiveX plug-ins for tasks ranging from multiuser coordination on MSN Games to Windows verification on MSDN.)

Silverlight vs Flash

The most successful browser plug-in is Adobe Flash, which is installed on over 90 percent of the world’s web browsers. Flash has a long history that spans more than ten years, beginning as a straightforward tool for adding animated graphics and gradually evolving into a platform for developing interactive content.

It’s perfectly reasonable for .NET developers to create web sites that use Flash content. However, doing so requires a separate design tool and a completely different programming language (ActionScript) and programming environment (Flex). Furthermore, there’s no straightforward way to integrate Flash content with server-side .NET code. For example, creating Flash applications that call .NET components is awkward at best. Using server-side .NET code to render Flash content (for example, a custom ASP.NET control that spits out a Flash content region) is far more difficult.

Silverlight aims to give .NET developers a better option for creating rich web content. Silverlight provides a browser plug-in with many similar features to Flash, but one that’s designed from the ground up for .NET. Silverlight natively supports the C# language and embraces a range of .NET concepts. As a result, developers can write client-side code for Silverlight in the same language they use for server-side code (such as C# and VB) and use many of the same abstractions (including streams, controls, collections, generics, and LINQ).

The Silverlight plug-in has an impressive list of features, some of which are shared in common with Flash, and a few of which are entirely new and even revolutionary. Here are some highlights:

Widespread browser support: It’s too early to tell how well the Silverlight browser works on different platforms. Currently, the beta builds of Silverlight 2.0 work on Windows Vista and Windows XP (in the PC universe) and OS X 10.4.8 or later (in the Mac world). The minimum browser versions that Silverlight 2.0 supports are Internet Explorer 6, Firefox 1.5.0.8, and Safari 2.0.4. Although Silverlight 2.0 doesn’t currently work on Linux, the Mono team is creating an open source Linux implementation of Silverlight 1.0 and Silverlight 2.0. This project is known as Moonlight, and it’s being developed with key support from Microsoft. To learn more, visit http://www.monoproject.com/Moonlight.

Lightweight download: In order to encourage adoption, Silverlight is installed with a small-size setup (about 4MB) that’s easy to download. That allows it to provide an all-important “frictionless” setup experience, much like Flash (but quite different from Java).

2D drawing: Silverlight provides a rich model for 2D drawing. Best of all, the content you draw is defined as shapes and paths, so you can manipulate this content on the client side. You can even respond to events (like a mouse click on a portion of a graphic), which makes it easy to add interactivity to anything you draw.

Controls: Developers don’t want to reinvent the wheel, so Silverlight is stocked with a few essentials, including buttons, text boxes, lists, and a grid. Best of all, these basic building blocks can be restyled with custom visuals if you want all of the functionality but none of the stock look.

Animation: Silverlight has a time-based animation model that lets you define what should happen and how long it should take. The Silverlight plug-in handles the sticky details, like interpolating intermediary values and calculating the frame rate.

Media: Silverlight provides playback of Windows Media Audio (WMA), Windows Media Video (WMV7 through WMV9), MP3 audio, and VC-1 (which supports high definition). You aren’t tied to the Windows Media Player ActiveX control or browser plug-in—instead, you can create any front end you want, and you can even show video in full-screen mode. Microsoft also provides a free companion hosting service (at http://silverlight.live.com ) that gives you space to store media files. Currently, it offers a generous 10GB.

The CLR: Most impressively, Silverlight includes a scaled-down version of the CLR, complete with an essential set of core classes, a garbage collector, a just-in-time (JIT) compiler, support for generics, threading, and so on. In many cases, developers can take code written for the full .NET CLR and use it in a Silverlight application with only moderate changes.

Networking: Silverlight applications can call old-style ASP.NET web services (ASMX) or Windows Communication Foundation (WCF) web services. They can also send manually created XML requests over HTTP. This gives developers a great way to combine rich client-side code with secure server-side routines.

Data binding: Although it’s not as capable as in its big brother, Windows Presentation Foundation (WPF), Silverlight data binding provides a convenient way to display large amounts of data with minimal code. You can pull your data from XML or in-memory objects, giving you the ability to call a web service, receive a collection of objects, and display their data in a web page—often with just a couple of lines of code.

Of course, it’s just as important to note what Silverlight doesn’t include. Silverlight is a new technology that’s evolving rapidly, and it’s full of stumbling blocks for developers who are used to relying on .NET’s rich libraries of prebuilt functionality. Prominent gaps include lack of database support (there’s no ADO.NET), no support for 3D drawing, no printing, no command model, and few rich controls like trees and menus (although many developers and component companies are building their own). All of these features are available in Windows-centric WPF applications, and they may someday migrate to the Silverlight universe—or not.


Source of Information : Apress Silverlight 2 Visual Essentials

What is Silverlight

Silverlight is a framework for building rich, browser-hosted applications that run on a variety of operating systems. Silverlight works its magic through a browser plug-in. When you surf to a web page that includes some Silverlight content, this browser plug-in runs, executes the code, and renders that content in a specifically designated region of the page. The important part is that the Silverlight plug-in provides a far richer environment than the traditional blend of HTML and JavaScript that powers ordinary web pages. Used carefully and artfully, you can create Silverlight pages that have interactive graphics, use vector animations, and play video and sound files.

If this all sounds familiar, it’s because the same trick has been tried before. Several other technologies use a plug-in to stretch the bounds of the browser, including Java, ActiveX, Shockwave, and (most successfully) Adobe Flash. Although all these alternatives are still in use, none of them has become the dominant platform for rich web development. Many of them suffer from a number of problems, including installation headaches, poor development tools, and insufficient compatibility with the full range of browsers and operating systems. The only technology that’s been able to avoid these pitfalls is Flash, which boasts excellent cross-platform support and widespread adoption. However, Flash has only recently evolved from a spunky multimedia player into a set of dynamic programming tools. It still offers far less than a modern programming environment like .NET.

That’s where Silverlight fits into the picture. Silverlight aims to combine the raw power and cross-platform support of Flash with a first-class programming platform that incorporates the fundamental concepts of .NET. At the moment, Flash has the edge over Silverlight because of its widespread adoption and its maturity. However, Silverlight boasts a few architectural features that Flash can’t match—most importantly, the fact that it’s based on a scaled-down version of .NET’s common language runtime (CLR) and allows developers to write client-side code using pure C#.

Silverlight uses a familiar technique to go beyond the capabilities of standard web pages: a lightweight browser plug-in. The advantage of the plug-in model is that the user needs to install just a single component to see content created by a range of different people and companies. Installing the plug-in requires a small download and forces the user to confirm the operation in at least one security dialog box (and usually more). It takes a short but definite amount of time, so it’s an obvious inconvenience. However, once the plug-in is installed, the browser can process any content that uses the plug-in seamlessly, with no further prompting.


Silverlight vs Flash

Silverlight 1.0 and 2.0

Silverlight and WPF

Silverlight and Visual Studio


Subscribe to Developer Techno ?
Enter your email address:

Delivered by FeedBurner