Chapter 12. Adding Silverlight Content to ASP.NET 3.5 Applications

We have already briefly discussed the ASP.NET 3.5 Extensions in Chapter 3. This package contains features and controls that are planned for future releases of ASP.NET and .NET. Some of these improvements have also been added to the Silverlight 2 Visual Studio project. The automatically generated test pages we have been using throughout this book are already using some of the new features, the <asp:Silverlight> control, now part of Silverlight.

Embedding XAML

The <asp:Silverlight> control lets you embed XAML content into an ASP.NET page. We will have a look at what the client-side HTML output looks like in a second; but before that, here are the most important attributes of <asp:Silverlight>:

Source

The URL of the Silverlight XAML file or .xap application to include.

Version

The minimum version of Silverlight that needs to be checked. If you are displaying Silverlight 2 content, set this property to 2.0.

ScaleMode

How to scale the embedded media. Possible values are ScaleMode.None (no scaling), ScaleMode.Stretch (stretch without keeping the aspect ratio), and ScaleMode.Zoom (stretch and keep the aspect ratio).

Width

The width (in pixels) of the Silverlight control.

Height

The height (in pixels) of the Silverlight control.

Here is an example:

<asp:Silverlight ID="Silverlight1" runat="server" 
  Source="MyApplication.xap" 
  Version="2.0" 
  Width="250" Height="250" />

To use this control, you may have to load the appropriate assembly, depending ...

Get Essential Silverlight 2 Up-to-Date now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.