Changes Between Silverlight 1.0 Beta and RTW

This document provides a list of new features, changes, and enhancements that have been made to Microsoft Silverlight version 1.0 since the Beta release (May 2007). It also provides a list of  changes that you might have to make in your Silverlight 1.0 Beta applications for compatibility with Silverlight 1.0 release to Web (RTW).

This topic includes the following sections:

  • Enhancements
  • Breaking Changes
    • Changes in event-handler syntax
    • Removal of "Sys." from namespaces
    • Changes in Silverlight.js
    • All Downloader downloads are asynchronous
    • FontUri for Glyphs object is resolved asynchronously
    • Visibility.Hidden is no longer supported
    • Extra check on ASX tags can result in a MediaFailed event
    • Parser error on invalid Double values such as "Auto"
    • OnLoad, OnError, OnResize, OnFullScreenChange event-handler syntax is function-pointer-based
    • Elements in resource blocks must be named
    • The MediaElement.Position property value can be greater than the MediaElement.NaturalDuration property value
    • Additional animation run-time errors
    • Backslashes not accepted in URIs
    • Shaped Transform members are of type Transform instead of TransformGroup
    • IsFilled property removed
    • AddEventListener returns a token to be passed to RemoveEventListener to unregister event handlers
    • Version property replaced with IsVersionSupported method
    • EnableHtmlAccess requires quotation marks
    • The width and height properties in CreateObject must be string values
    • Tighter restrictions of which objects can have child objects
    • Downloader can download only from the same port as the HTML

Enhancements

Silverlight 1.0 RTW provides the following new and enhanced features:

  • New Root property on the content sub-object of the Silverlight plug-in. This property enables access to the root element of the XAML tree in the Silverlight object model.
  • New Tag property on UIElement. This property enables user storage on every Silverlight UIElement.
  • New MediaElement APIs for selecting different audio streams out of a file with multiple audio tracks. For details, see the AudioStreamCount and AudioStreamIndex properties.
  • Improved media performance: optimized assembly instructions for the video decode.
  • Media script commands encoded in a separate stream in the video file now raise the MarkerReached event on the MediaElement object.
  • Added support for Adobe Compact Font Format (CFF) fonts.
  • Improved performance for transparent controls on Apple Safari.

Breaking Changes

The following sections describe the breaking changes between Silverlight 1.0 Beta (May 2007) and Silverlight 1.0 RTW. If you have created applications for Silverlight 1.0 Beta, please update your applications using this list as a guideline. Use the code samples, where provided, to ensure that your application runs on both versions of Silverlight 1.0.

Changes in event-handler syntax

Remove "javascript:" from event handlers in your code. For example, to attach an event handler, change your code as follows.

Silverlight 1.0 Beta:

XAML
<canvas onMouseLeftButtonDown="javascript:myhandler"  /> 

Silverlight 1.0 RTW:

XAML
<canvas onMouseLeftButtonDown="myhandler" />  

Removal of "Sys." from namespaces

The Sys namespace has been removed. Make sure to delete "Sys." from namespaces in your code, as shown in the following example.

Silverlight 1.0 Beta:

JavaScript
Sys.Silverlight.createObject(....)   

Silverlight 1.0 RTW:

JavaScript
Silverlight.createObject(....)   

Changes in Silverlight.js

Make sure that you use the latest Silverlight.js file (provided in the Silverlight SDK) in your applications. The following changes have been made to this file:

  • In the registration information, the plug-in name has changed from "WPFe Plug-In" to "Silverlight Plug-In". The functions in the Silverlight.js file refer to this plug-in name to detect Silverlight on the system.
  • The MIME type of the plug-in has changed from application/ag-plugin to application/x-silverlight.
  • As mentioned in the previous section, the namespace "Sys." was removed from Silverlight.js. Make sure to remove all instances of "Sys." from your Silverlight.js function scripting calls.

All Downloader downloads are asynchronous

The Downloader object no longer supports synchronous downloads, so the third (Boolean) parameter was removed from the Open method for the object. You must update Downloader.Open calls to remove the third parameter if it is specified, as shown in the following example.

JavaScript
function download(host, file) {
  var dl = host.createObject("downloader");
  dl.addEventListener("completed", downloadComplete);
  // If beta version, add the extra argument.
  if (_mix) {
    dl.open("get", file, true);
  } else {
    dl.open("get", file);
  }
  dl.send();
} 

FontUri for Glyphs object is resolved asynchronously

When the XAML code is processed, the font specified by the Glyphs object's FontUri property is downloaded separately and asynchronously. This means that text displayed by the Glyphs object will appear when the font is downloaded, in most cases, after other content has already appeared.

In Silverlight 1.0, there is no event that specifies the download progress when you use the FontUri property for a glyph. To work around this limitation, you can use the Downloader object to first request the font file. This enables you to use the Downloader object's progress and completion events to determine when the font file has been downloaded.

When the Downloader has finished downloading the font, you can create a Glyphs object with the FontUri property and specify the same font file URI. Because the font is already downloaded, it will not be downloaded again, and the Glyphs object should render almost instantaneously.

Note   This workaround makes the assumption that the downloaded font will remain in the browser's cache and will be picked up when the Glyphs object attempts to download the same file. But because the cache retention behavior is user- and browser-specific, the actual run-time behavior is uncertain.

Visibility.Hidden is no longer supported

In Silverlight 1.0 Beta, the Hidden value of the Visibility enumeration produced the same behavior as the Collapsed value. In Silverlight 1.0 RTW, the Hidden value is no longer supported. To create content that will work consistently in Silverlight 1.0 Beta and RTW, replace all occurrences of Hidden in both XAML and JavaScript with Collapsed, as shown in the following examples.

Silverlight 1.0 Beta (JavaScript):

JavaScript
sender.findName("fsm").visibility = "Hidden";

Silverlight 1.0 RTW (JavaScript):

JavaScript
sender.findName("fsm").visibility = "Collapsed";

Silverlight 1.0 Beta (XAML):

XAML
<Canvas x:Name="mask" Visibility="Hidden">

Silverlight 1.0 RTW (XAML):

XAML
<Canvas x:Name="mask" Visibility="Collapsed">

Extra check on ASX tags can result in a MediaFailed event

A set of unsupported Advanced Stream Redirector (ASX) tags -- PREVIEWMODE, BANNERBAR, PARAM, REPEAT, STARTMARKER, ENDMARKER, and some MOREINFO tags -- were ignored in Silverlight 1.0 Beta. These tags now result in a MediaFailed event.

Furthermore, if an ENTRY tag has multiple REF children, only the first one is read. Silverlight does not attempt to open additional REF URLs in case the first one fails, and a MediaFailed error is raised.

Parser error on invalid Double values such as "Auto"

Silverlight 1.0 RTW reports a greater number of parser errors than Silverlight 1.0 Beta. A parser error is raised in cases where you set a numeric property (typically typed as Double, but also possibly with integer values) to an invalid value. In the Beta release, an invalid value was treated as 0 (zero), but Silverlight 1.0 RTW throws an error instead. For example, the following code results in a parser error.

XAML
<TextBlock Width="Auto" Text="Created By:" />

In Silverlight 1.0 Beta, a Width value of "Auto" is not supported, and causes the width to be set to 0 (zero). (This setting does not affect the application, because the TextBlock object is not clipped by the Width property.) In Silverlight 1.0 RTW, the same XAML generates a parser error.

OnLoad, OnError, OnResize, OnFullScreenChange event-handler syntax is function-pointer-based

In Silverlight 1.0 RTW, the OnLoad, OnError, OnResize, and OnFullScreenChange events require event-handler syntax that is a function pointer-based instead of string-based. To develop Silverlight content that works on both Beta and RTW releases, check the version and provide the appropriate conditional code.

Elements in resource blocks must be named

Elements in resource blocks must be named. This means that you must have a x:Name or Name attribute for all content in a Resources section, as shown in the following example.

Silverlight 1.0 Beta:

XAML
<Canvas.Resources>
    <Storyboard>
        <!-- Content here... -->
    </Storyboard>
</Canvas.Resources>
 

Silverlight 1.0 RTW:

XAML
<Canvas.Resources>
    <Storyboard x:Name="name">
        <!-- Content here... -->
    </Storyboard>
</Canvas.Resources>
 

The MediaElement.Position property value can be greater than the MediaElement.NaturalDuration property value

This situation will mostly be seen in broadcast cases, which had previously returned 0 for the Position value but now return the play time. If you are creating media transport controls, you should be aware of this possibility, and you might need to clip the media, as shown in the following example.

Silverlight 1.0 Beta:

JavaScript
// Set the slider thumb position in the right range of the track's width.
// Assumes position is never greater than media's naturalDuration.
sliderThumb["Canvas.Left"] = (myME.position.seconds/myME.naturalDuration.seconds)*sliderTrack.width;

Silverlight 1.0 RTW:

JavaScript
// Need to clip the slider position by the track's width.
if (myME.position.seconds >= myME.naturalDuration.seconds)
  	sliderThumb["Canvas.Left"] = sliderTrack.width;
else
sliderThumb["Canvas.Left"] = (myME.position.seconds/myME.naturalDuration.seconds)*sliderTrack.width;

Additional animation run-time errors

Silverlight 1.0 RTW is stricter than Silverlight 1.0 Beta when handling animation run-time errors. For example, failing to observe the following causes run-time errors:

  • Storyboard.TargetProperty must be defined on all animations before they are started. Storyboard.TargetName must either be specified on the animations themselves or on a parent Storyboard before they are started.
  • Certain Storyboard animation properties can be modified only when the Storyboard is stopped. These properties include Storyboard.TargetName and Storyboard.TargetProperty.

Backslashes not accepted in URIs

Backslashes (\) are no longer accepted in URIs, to maintain the cross-platform support of Silverlight-based applications. When you specify Web resources, use URIs with forward slashes (/) instead of backslashes. For example, use "./assets/images/bg.jpg" instead of ".\assets\images\bg.jpg".

Shaped Transform members are of type Transform instead of TransformGroup

All shaped Transform members are now of type Transform instead of TransformGroup. This behavior has been changed for consistency with Windows Presentation Foundation (WPF). For example, in Silverlight 1.0 RTW, brush_instance.relativeTransform.toString() returns "Transform" instead of "TransformGroup".

IsFilled property removed

The IsFilled property on the PathFigure object is no longer supported. Remove references to this property from your code, as shown in the following example.

Silverlight 1.0 Beta:

XAML
<PathFigure IsFilled="true" .../>

Silverlight 1.0 RTW:

XAML
<PathFigure .../>

AddEventListener returns a token to be passed to RemoveEventListener to unregister event handlers

If you intend to remove event handlers during the lifetime of your Silverlight-based application, you must change the syntax you use to add the event handlers. The AddEventListener method now returns a token that is necessary for the RemoveEventListener call. The token differentiates between event handlers when multiple handlers are attached to the same event. If you do not intend to remove event handlers, you can leave your AddEventListener calls unchanged. However, note that AddEventHandler now supports adding the handlers by reference as well as quoted name string. This change was made for consistency with other scripting object model syntaxes. The following examples show the changes you should make in your JavaScript and XAML code.

Silverlight 1.0 Beta (JavaScript):

JavaScript
myObj.addEventListener("MouseEnter", myEnterHandler);
myObj.removeEventListener("MouseEnter", myEnterHandler);

Silverlight 1.0 RTW (JavaScript):

JavaScript
var enterToken = myObj.addEventListener("MouseEnter", myEnterHandler);
myObj.removeEventListener("MouseEnter", enterToken);

Silverlight 1.0 Beta (XAML):

XAML
<... x:Name="myObj" MouseEnter="myEnterHandler"/>
JavaScript
sender.FindName("myObj").removeEventListener("MouseEnter", myEnterHandler);

Silverlight 1.0 RTW (XAML):

XAML
<... x:Name="myObj" MouseEnter="myEnterHandler"/>
JavaScript
sender.FindName("myObj").removeEventListener("MouseEnter", 0);

Version property replaced with IsVersionSupported method

The Version property of the Silverlight plug-in is no longer supported. Instead, the IsVersionSupported method checks the installed version of Silverlight. The IsVersionSupported result anticipates the behavior that would occur if you called Silverlight.CreateObject. If IsVersionSupported returns true, when your instantiation scripting calls Silverlight.CreateObject, the user sees your Silverlight content, with no preliminary installation UI. If IsVersionSupported returns false, when your instantiation scripting calls Silverlight.CreateObject, the user sees preliminary installation UI. (For details, see Instantiating a Silverlight Plug-In).

EnableHtmlAccess requires quotation marks

In Silverlight 1.0 RTW, you must add quotation marks to the enableHtmlAccess value, as shown in the following example.

Silverlight 1.0 Beta:

JavaScript
enableHtmlAccess: true

Silverlight 1.0 RTW:

JavaScript
enableHtmlAccess: "true"

The width and height properties in CreateObject must be string values

The width and height properties in the CreateObject function call must be string values, not integer values.

Tighter restrictions on which objects can have child objects

Silverlight 1.0 RTW tightens the restrictions on which objects can have child objects. For example, Rectangle and TextBlock could have child objects in Silverlight 1.0 Beta, but this is no longer permitted in Silverlight 1.0 RTW and will result in a parser error.

Downloader can download only from the same port as the HTML

In Silverlight 1.0 RTW, the Downloader object can download only from the same port as the HTML file that hosts the Silverlight plug-in.

See Also

Silverlight Overviews and How-to Topics
Silverlight Reference