What's Changed in Silverlight 2 Beta 2?

June 6, 2008
No Comments.

Silverlight Logo
The Silverlight Team has been burning the candles at both ends. To our benefit they have delivered Beta2 of Silverlight 2. The changes between Beta 1 and Beta 2 are not as dramatic as you may have experienced between Silverlight 1.1 Alpha and Silverlight 2 Beta 1.  But some major changes have been made.

There are specific instructions about what code actually needs to be fixed in your projects.  These instructions are contained in the change documentation that ship with the Beta 2 package.  You can download the new Silverlight 2 Beta 2 from the site:

Scott Guthrie also has a detailed post of some of the changes and a nice walkthrough of using the VisualStateManager and ControlTemplate authoring with Blend:

Here are the changes that I found while converting my old sites and writing some new sites:

Framework Changes

SDK Controls versus Plugin Controls

The most starling change for me was the fact that they merged most of the controls that used to be in **System.Windows.Controls.dll **into the System.Windows.dll assembly. The impact this has is to reduce the overall size of a .xap file since you can now depend on most of the controls from the plug-in.  In Silverlight 2 Beta 1 a “Hello World” app’s .xap file started at an astounding 230K in size.  In contrast the Beta 2 “Hello World” .xap is only 4K.

Microsoft has the challenge of putting as much functionality as possible in the plug-in without it getting so large that is off-putting to users to download and install.  The inclusion of the controls into the runtime has ballooned it up from 4MB to about 4.5MB, but overall I think this was a critical decision.

Isolated Storage Size

The default size of Isolated Storage is now at 1MB (instead of 1KB in Beta 1).

Event Bubbling Cancellation

In Beta 1 (and prior), event bubbling could not be cancelled.  The framework allowed you to mark the event as handled, but not actually stop the bubbling from occurring.  In Beta 2 this changes and when you mark an event as handled, it is not propogated through the render tree:

void nested_MouseEnter(object sender, MouseEventArgs e)
  // Cancels the bubbling
  e.Handled = true;

Silverlight.js has Changed

The Silverlight.js script has been changed and updated in the Beta 2 SDK so you will need to replace this script anywhere you are deploying Beta 2 projects to ensure compatibility.

DataBinding Changes

The FrameworkElement class (the base class of most visual elements in Silverlight) now supports a BindingValidationError event that is thrown when data binding fails to correctly bind to TwoWay binding. To support this, the Binding class now supports NotifyOnValidationError and ValidatesOnExceptions properties to turn on validation error notification.

Code-only Storyboards

You can now create Storyboards in code that can animation parts of the render tree without having to be added to the render tree.  This allows you to create Storyboards (and embedded animations) in code alone.

Cascading Properties

Beta 2 moves a number of important properties to the Control class which has the effect of allowing you to specify these properties on the UserControl and have the child Control’s default properties to cascade.  These properties include:

  • Foreground
  • FontFamily
  • FontSize
  • Etc.

If you set these in the UserControl (or other Control-based parent), the children will ‘inherit’ these properties.  For example:

<UserControl x:Class="SilverlightApplication5.Page"
  <Grid x:Name="LayoutRoot">
    <TextBox Text="Hello" />

XamlReader and Namescopes

Using the XamlReader to build dynamic XAML at runtime has the side effect now of always creating a namescope for the XAML.  Prior to Beta 2, you could optionally create a namescope.

If you’re not familiar with namescopes, this blog entry explains it really well:

Control Changes

Changed TemplateParts

If you have used ControlTemplates in your Silvelright 2 Beta 1 applications, some of the templates (most notably the TextBox) have changes quite a bit. This means that you may need to rename some of the TemplateParts in your applications to make them continue to work.  Review the TemplateParts for any control where you are using a ControlTemplate.  The behavior when you have a mismatch between ControlTemplates is that the rendering will simply fail and your app stop working.  Unfortunately there are no compile-time checks or exceptions thrown when you get this wrong.

Introducing the VisualStateManager

In Beta 2, Microsoft introduces a new concept to handle changes to the UI in reaction to user input.  For example, handling when a user hovers over a control, the control has focus, etc. Prior to Beta 2 you would define TemplateParts for Storyboards but the way this is defined was hard for designers to handle when creating a control.  To The VisualStateManager instead has groups of Visual States that each have their own duration and other properties. Effectively it means that it will be easier for designers (using Blend or in raw XAML) to create these transitions than was possible prior to Beta 2.

There isn’t enough room in this blog post to explain it in detail but I should be posting something in depth about this very soon.

New Control: TabControl

Added to Beta 2 is a TabControl class that supports standard tab control functionality.

Multiline TextBox

The TextBox now supports multi-line data entry via the new AcceptsReturn and TextWrapping properties.  These will allow you to specify the exact behavior you want (instead of simply enabling multi-line support.

WatermarkedTextBox is Gone

The WatermarkedTextBox control has been removed.  There may be ways of accomplishing this without the control, but there are no current plans to re-introduce this control.

Extended Control Changes

The System.Windows.Controls.Extended.dll still exists and contains some key controls that you might need:

  • Calendar
  • DatePicker
  • GridSplitter
  • TabControl

In order to use these controls you will need to import the assembly into your project and import the namespace into your XAML.  No longer will these work with the default namespace.

Tooltip Changes

ToolTips can no longer be set directly but must use the ToolTipService class to add it to any element. For example:

<Button ToolTipService.ToolTip="This is ToolTip text"/>

DeepZoom Changes

As part of Beta 2, there is a new DeepZoom Composer tool.  Prior to Beta 2, the image information was a collection of images and a binary file (.bin) that contained the metadata about the the images.  In Beta 2, this file is now an xml file to support consistency and versioning (called .dzi).

DataGrid has Changed

The DataGrid has continued to mature to include new features like column reordering, row sorting and more granular control templates.  Any DataGrid’s you are currently using may need to be reworked…but you will get a lot more functionality than you had in Beta 1.

Networking Changes

Web Service Changes

Web Services now support cross-domain service requests (using the cross-domain policy files). WCF Services now support duplex services but basicHttpBinding is still the only supported binding.

ADO.NET Data Services Support

The ADO.NET Data Services (aka Astoria) client support for Silverlight is now included in the SDK. Note that you need .NET 3.5 SP1 (beta) and Visual Studio 2008 SP1 (beta) both installed to write the server-side ADO.NET Data Services to make this work, but the client library is now included.  It has a similar model to the .NET Client Library but all requests are asynchronous.  I *will* be covering this soon in articles and in this blog so if you’re interested in ADO.NET Data Services from Silverlight 2…its coming.

Web Request Exception Changes

Prior to Beta 2, any exceptions during an asynchronous web request would happen on the background thread making it difficult to handle exceptional conditions. In Beta 2, the exception will be thrown as the accessor to the Result is called. This means you will now need to use try…catch blocks around access to the Result property to catch security exceptions in your web request code.


Web Service calls that are made using a Service Reference will now use the setting contained in the ServiceReference’s .clientconfig file (a new file generated during the proxy generation).  If you want to make changes to the service binding or other parameters, making them in the .clientconfig file is now the way to do that.

Header Support in Cross Domain Policy

In Beta 2, the cross domain requests now specifically prohibit the use of headers unless they are allowed in the cross domain policy file.

Sockets Change

Sockets now support connections to any server that enables the cross domain policy files.  In addition, the range of ports has been widened to allow for more typical socket communication to be available.

Tool Changes

Silverlight Linkage Changes

Links between ASP.NET projects and Silverlight projects now allow you to specify build-specific directories so you can have two versions of a .xap file (e.g. Debug and Release). In addition, the “Add Silverlight Link…” option on the context menu has been removed.  You can create links to Silverlight projects (and make changes) now in a new Silverlight Tab in the Project properties of the ASP.NET projects.

“Add Service Reference…” Changes

The default collection type for Data Contracts is now ObservableCollection<> (which you can still change with the “Advanced” options. If you’re not familiar with the collection type, the **ObservableCollection<> **type can notify a container when the collection changes (e.g. add/remove/insert). This is used by Silverlight’s Data Binding to allow OneWay and TwoWay bindings to work against collections.  The switch from Array to ObservableCollection<> is the right decision AFIAC.

Blend Changes

Blend 2 June Preview includes new features to make some common tasks easier to use including:

  • ControlTemplate editing support in Blend
  • VisualStateManager Support (to create state transitions)
  • New Breadcrumb Navigation in designer
  • Enabled the “Make Button” functionality (Select items and make a button control template from those items).
  • Font Embedding Support (if you drop a font in your Silverlight 2 project, it will be available from the list of Fonts).

What is Still Missing?

There is still room for improvement and certainly as we head into Silverlight 2 RTM, I expect to see more additions.  Here is a list of what I think is still missing and from Microsoft’s public statements, they are likely to be included:

  • ProgressBar control
  • ComboBox control
  • Better WCF Support

Whew!  I am sure I didn’t cover all the changes but these are the big ticket items that I saw in converting my own projects over.  Let me know in comments if you find more.