Printer Friendly Version      Send     
Click to Rate and Give Feedback
MSDN
MSDN Library
Silverlight Technical Articles
What's New in Silverlight (1.0 Beta and 1.1 Alpha)?
 

David Pugmire

Microsoft Corporation

April 2007

Applies to:
   Silverlight 1.0 Beta
   Silverlight 1.1 Alpha

Note: The information in this article is out of date. For current information, see Breaking Changes in Silverlight 2.

Summary: This white paper provides a simple and concise list of new features, changes or enhancements that have been made to Silverlight since the February 2007 CTP. This is not intended to be an exhaustive list with details, with the exception of breaking changes information. Please also refer to the Silverlight SDK for more information on each of the items mentioned here.

Contents

Silverlight 1.0 Beta Enhancements
Silverlight 1.1 Alpha
Breaking Changes

Silverlight 1.0 Beta Enhancements

  • Improved install experience
  • VideoBrush (used to paint shapes and text with video content)
  • WMS streaming support
  • Media markers/script command support
  • Playlist support (ASX subset)
  • Improved video playback smoothness
  • Cleaned-up animation model
    • Animations now go in a Canvas.Resources block
  • Support for downloading and unpacking .zip files
  • Support for cross-domain downloads
  • Improved text rendering
  • Ink support
  • Improved javascript programming
    • Enum support
    • Better error handling
    • Support for delegates as event handlers
    • Sandboxed javascript mode
  • Namescope support
  • New properties for UI manipulation:
    • Z-Index
    • Visibility
    • IsHitTestVisible
  • Downloading fonts for TextBlock

For a complete set of descriptive information on these items, please see the Silverlight SDK.

Silverlight 1.1 Alpha

Silverlight 1.1 Alpha in and of itself is completely new to Silverlight. Designers and developers can now build their Silverlight applications based upon managed code.

For more information about Silverlight 1.1, visit http://silverlight.net.

Breaking Changes

Notable changes to the Silverlight 1.0 Beta API have been made since the February 2007 CTP. If you built an application using the February CTP and would like to update it to work in Silverlight 1.0 Beta, please follow the guidance in this section. Silverlight 1.1 Alpha is also addressed in this section, as it applies.

Control Instantiation

The major change to control instantiation is that rather than one helper file, we are now providing two: createSilverlight.js and Silverlight.js. Silverlight.js contains new namespaces "Sys.Silverlight" that expose two methods, createObject() and createObjectEx(). Sys.Silverlight.createObject() is roughly equivalent to agHost(). It takes parameters that are passed to the <object> tag for control/plugin instantiation. Sys.Silverlight.createObjectEx() is functionally equivalent to Sys.Silverlight.createObject(), but takes a single JSON dictionary of parameters.

We've provided a second helper file, createSilverlight.js, that contains a single call: createSilverlight(). createSilverlight() should be inserted into HTML and should contain calls to Sys.Silverlight.createObject() or to Sys.Silverlight.createObjectEx().

An example of an HTML page using createSilverlight.js is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html  >
<head>
    <title>Grand Piano</title>    
    <script src="class/Piano.js" type="text/javascript"></script>
    <script src="class/Silverlight.js" type="text/javascript"></script>
    <script src="class/CreateSilverlight.js" type="text/javascript"></script>
</head>
<body>
    <form>
        <div id="AgControl1Host" style="background:#FFFFFF">     
       <script type="text/javascript">                                            
            var pe = document.getElementById("AgControl1Host");
            createSilverlight();                  
        </script>  
        </div>
    </form>            
</body>               
</html>

Following is an example of the createSilverlight() call, contained in the separate createSilverlight.js:

function createSilverlight()

{      
    Sys.Silverlight.createObject("xaml/piano.xml", pe, "AgControl1",
        {width:'1024', ignoreBrowserVer:false, height:'530',                     inplaceInstallPrompt:true, background:'white',
          isWindowless:'false', framerate:'24', version:'0.90'},
        {onError:null, onLoad:null},
        null);                               
                             
    
}    

In the alternative, you can use your own custom function to call Sys.Silverlight.createObject() or Sys.Silverlight.createObjectEx(). The <script/> block in the first example above would then be changed to:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html  >
<head>
    <title>Grand Piano</title>    
    <script src="class/Piano.js" type="text/javascript"></script>
    <script src="class/Silverlight.js" type="text/javascript"></script>
    <script src="class/CreateSilverlight.js" type="text/javascript"></script>
</head>
<body>
    <form>
        <div id="AgControl1Host" style="background:#FFFFFF">     
       <script type="text/javascript">                                            
            var pe = document.getElementById("AgControl1Host");
            myCustomFunction();                  
        </script>  
        </div>
    </form>            
</body>               
</html>

Version Detection

Silverlight 1.0 Beta and 1.1 Alpha will follow this versioning scheme:

  • Silverlight 1.0 Beta version is "0.90.build"
  • Silverlight 1.1 Alpha version is "0.95.build"

Silverlight.js contains a "version" property that checks for the proper version and directs users to the install location if the proper version is not installed.

Plug-in API Changes

  • The javascript hosting model for the Silverlight plug-in has changed. Use the Silverlight.js file included in the Silverlight Visual Studio 2005 project templates instead of the old agHost.js file.
  • The APIs on the "WPF/E" plug-in have been refactored. Use the table below to update any API calls.

    Table 1. Script syntax changes

    Old Script New Script
    Control.background Control.settings.background
    Control.windowless Control. settings.windowless
    Control.version Control. settings.version
    Control.maxFrameRate Control. settings.maxFrameRate
    Control.enableFrameRateCounter Control. settings.enableFrameRateCounter
    Control.enableRedrawRegions Control. settings.enableRedrawRegions
    Control.actualWidth Control.content.actualWidth
    Control.actualHeight Control.content.actualHeight
    Control.fullScreen Control.content.fullScreen
    Control.findName Control.content.findName
    Control.createFromXAML Control.content.createFromXAML
    Control.createFromXAMLDownloader Control.content.createFromXAMLDownloader
    Control.fullScreenChange Control.content.onFullScreenChange
    Control.OnResized Control.content.onResize
Note   When the Control is sent to Javascript via a functions argument such as function(Sender, Args), ".content" does not need to be used to access methods such as findName, etc. If, however, the gethost() method is used to get the Control (even if it is used with a functions arguments), ".content" needs to be used. For example:

When "content" is required:

function myFunc(Sender, Args)
{
     var myHost = Sender.getHost();
     var playButton = myHost.content.findName("playButton");
}

When "content" is not required:

function myFunc(Sender, Args)
{
     var playButton = Sender.findName("playButton");
}

The Source and SourceElement properties on the plug-in have been combined into one called "Source." When specifying the Source property value as an id for a SCRIPT block containing XAML markup, you need to prefix the id with a hash (#) character.

Table 2. SourceElement becomes Source

Old New
<script id="myXamlFragment" type="text/xaml">

//some markup

</script>

<object …>

<param name="SourceElement" value="myXamlFragment"/>

<!-- other params -->

</object>

<script id="myXamlFragment" type="text/xaml">

//some markup

</script>

<object …>

<param name="Source" value="#myXamlFragment"/>

<!-- other params -->

</object>

  • The SourceString property was removed from the plug-in. The createFromXaml method enables scenarios that would have previously used SourceString.
  • The error handling mechanism has been significantly upgraded (see "error handling" in the Silverlight SDK for more information on error handling). If you relied on agHost.js to provide default error handling, then swapping in the updated silverlight.js is all that is required.
    • The onError event handler takes two parameters: the sender object, and the event arguments. The sender is the object that the error occurred on. The event argument is an instance of ErrorEventArgs—or one of its derived objects (ParserErrorEventArgs or RuntimeErrorEventArgs)—depending on the type of error.
  • The downloader object now supports extracting items out of a .zip file that has been downloaded. This requires a new parameter on the setSource method on MediaElement, Image and ImageBrush. These methods now take a second parameter specifying the item from the .zip file to be used. If downloaded item is a single file, the second parameter must be the empty string.

    Old:

    myMediaElement.setSource(myDownloader);

    New:

    myMediaElement.setSource(myDownloader, "");

Animations

  • "Interactive storyboards" (ones that do not begin on the Loaded) are now placed in Canvas.Resources.
    • The BeginTime="1" hack used to specify an "interactive storyboard" is no longer needed, and should be removed.
    • The meaning of Storyboard.Begin() has also been fixed. It used to ignore the BeginTime attribute on the Storyboard; now it will take it into account. For example, calling Begin() on a Storyboard that has BeginTime="0:0:5" will begin the Storyboard 5 seconds after the time Begin() was called.

      Old:

      <Canvas.Triggers>
         <EventTrigger RoutedEvent="FrameworkElement.Loaded">
            <BeginStoryboard>
               <Storyboard x:Name="imageBlur" BeginTime="1">
                  <DoubleAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetName="blurImage" Storyboard.TargetProperty="Opacity">
                     <SplineDoubleKeyFrame KeyTime="00:00:00.7" Value="1"/>
                  </DoubleAnimationUsingKeyFrames>
               </Storyboard>
            </BeginStoryboard>
         </EventTrigger>
      </Canvas.Triggers>

      New:

      <Canvas.Resources>
         <Storyboard x:Name="imageBlur">
            <DoubleAnimationUsingKeyFrames BeginTime="0" Storyboard.TargetName="blurImage" Storyboard.TargetProperty=" Opacity">
               <SplineDoubleKeyFrame KeyTime="00:00:00.7" Value="1"/>
            </DoubleAnimationUsingKeyFrames>
         </Storyboard>
      </Canvas.Resources>
  • The RoutedEvent property on EventTrigger is now validated properly. You must explicitly specify the element type with the loaded event name.

    Old:

    <EventTrigger RoutedEvent="Loaded"> or <EventTrigger RoutedEvent="FrameworkElement.Loaded">

    New:

    <EventTrigger RoutedEvent="Canvas.Loaded">

Event Handlers

  • MouseEventArgs no longer have an x and y property. A new method called getPosition allows mouse coordinates to be obtained in relation to the transform space of a specified UIElement has been added. If you specify null to this method, the February CTP behavior is obtained.

    Old:

    var var1 = eventArgs.x;

    New:

    var var1 = eventArgs.getPosition(null).x;
  • Event handlers no longer require the "javascript:" prefix. Using "javascript:" is not recommended but is optional for Silverlight 1.0 Beta. This will be disallowed in future versions.
  • Event handlers added in javascript must now use addEventListener instead of the property syntax for attaching event handlers.

    Old:

    myCanvas["mouseEnter"] = "javascript:handleMouseEnter";

    New:

    myCanvas.addEventListener("mouseEnter", "handleMouseEnter");
  • For a XAML tree in Silverlight, the OnLoad event will be invoked once after the loaded events on every element on the tree has been fired. The OnLoad event is an approximation of "the tree has been laid out and about to be rendered." The event is fired only the first time the content is loaded.

    Usage with OBJECT tag:

    <script type="text/javascript">
      // When XAML content has loaded, crunch some numbers
      function CrunchSomeNumbers(sender, eventArgs)
      {
        CrunchSomeMoreNumbers(sender);
      }
    </script>
    
    <object…>
      ...
      <param name="OnLoad" value="CrunchSomeNumbers" />
    </object>

    Or, using script and Silverlight.js:

    <script type=text/javascript>
        // instantiate the Silverlight plugin
        var silverlightPlugin = Sys.Silverlight.createObject(
            "MyPage.xml", pe, "AgPlugin",
                {width:'1024', height:'530', ..., version:'0.8'},
                 {onError:null, onLoad:'CrunchSomeNumbers'},
                 null);
    </script>
© 2008 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker