(X) Hide this
    • Login
    • Join
      • Generate New Image
        By clicking 'Register' you accept the terms of use .

Silverlight 3 RTW overview

(3 votes)
Martin Mihaylov
>
Martin Mihaylov
Joined Oct 29, 2007
Articles:   50
Comments:   70
More Articles
2 comments   /   posted on Jul 10, 2009
Categories:   General

The official release of Silverlight 3 is already a fact and at Silverlight.net you can find the latest files for download. For more information on how to get started with the new Silverlight 3, pay a visit to our Get Started page.

With the official release there are a lot of changes that will affect in some way the Silverlight 2 and Silverlight 3 Beta applications. As the list of changes is pretty long, I will overview only the most interesting of them, but to be fully intact with the new release and to convert your application as fast and easy as possible, be sure to read this breaking changes document, provided by the Silverlight SDK team.

What about the Silverlight 2 applications after the Silverlight 3 release?

There have already been published some posts that gave a fare answer to this question, but I think this is a good place and time to summarize the information on the topic.

In Silverlight 3 there are many Silverlight 2 bug fixes and changes that will normally break your old Silverlight 2 application, but they won’t. That’s because the Silverlight developers made these fixes and changes as “quirk mode changes”. Quirk mode changes don’t get enforced by the Silverlight 3 runtime if it detects that the runtime version of the application is 2.0. However, those changes are in power for applications designed with Silverlight 3. The Silverlight 3 runtime is able to determine for which version the application was designed thanks to the RuntimeVersion attribute in the AppManifest.xaml. This version represents the build of Silverlight with which the application was compiled.

Although your Silverlight 2 applications will work normally under the Silverlight 3 runtime, if you try to recompile them with Silverlight 3, you will have to convert your application considering the bug fixes and changes. So before converting read carefully the document with the breaking changes.

Controls

Here is a list of controls that are removed from the Silverlight 3 SDK to the Silverlight Control Toolkit:

  • DockPanel
  • WrapPanel
  • Expander
  • HeaderedContentControl
  • Viewbox
  • DataForm
  • ExpandDirection
  • ExpanderAutomationPeer
  • LengthConverter
  • StretchDirection

You can donwload the Silverlight Control Toolkit at http://www.codeplex.com/silverlight.

Data Visualization

This is the first group of changes that we are going to take a look at. The focus of the section will fall over the DataForm, DataPager and the attributes that were introduced with the Beta version of Silverlight 3.

DataForm

As mentioned above, the DataForm control is now part of the Silverlight Control Toolkit. The other major change regarding the DataForm is the removing of the Fields collection property and the removing of all DataFormFields. On their place a new control is introduced – the DataField control. It wraps content with a Label and a DescritpionViewer and compared with the DataFromFiled controls can be used as a standard control (for example placed in other layout controls). On the place of the Fields collection are introduced three template properties – EditTemplate, NewItemTemplate, ReadOnlyTemplate. Use them to define your DataFields for the specific DataForm mode. For example, here is how to define the DataField for the Username property when the DataForm is in edit mode:

<df:DataForm x:Name="MyDataForm">
    <df:DataForm.EditTemplate>
        <DataTemplate>
            <df:DataField>
                <TextBox Text="{Binding Username, Mode=TwoWay}" />
            </df:DataField>
        </DataTemplate>
    </df:DataForm.EditTemplate>
</df:DataForm>

Note: In the old DataFormFields there was no need to explicitly set the Mode of the binding to TwoWay. As now standard controls are used for the content of the DataField, you have to explicitly set the Mode of the binding to TwoWay.

Two other properties of the DataForm are also removed – Orientation and WrapAfter. As I mentioned before, the DataField control can be used as a standard Silverlight control, which means that you can place it inside layout controls such as StackPanel, WrapPanel, DockPanel,etc. In this way you can easily achieve the effect of the Orientation and WrapAfter properties. You can also set the DataField.IsFieldGroup attached property of the layout control, containing the DataFields, to indicate that the DataFields in it belong to a particular group. In this way their labels will be grouped together by width.

<df:DataForm x:Name="MyDataForm">
    <df:DataForm.EditTemplate>
        <DataTemplate>
            <StackPanel df:DataField.IsFieldGroup="True">
                <df:DataField>
                    <TextBox Text="{Binding Username, Mode=TwoWay}" />
                </df:DataField>
                <df:DataField>
                    <TextBox Text="{Binding Email, Mode=TwoWay}" />
                </df:DataField>
                <df:DataField>
                    <TextBox Text="{Binding BirthDate, Mode=TwoWay}" />
                </df:DataField>
            </StackPanel>
        </DataTemplate>
    </df:DataForm.EditTemplate>
</df:DataForm>

DataPager

The type of the Source property of the DataPager is changed from IPagedCollectionView to IEnumerable. This means that now the DataPager can work with a larger range of collection. When a collection that doesn’t implement the IPagedCollectionView is given to the DataPager, it treats it like a collection with a single large page of items.

Attributes

In the Silverlight 3 Beta new attributes were introduced, that were to help you easily work with data. One of them was the Bindable attribute. Its purpose was to annotate if a property of a business object should be auto-generated in the UI and should it be editable:

//The proeprty Username can be auto-generated in the UI,
//but is not editable, because of the one way binding.
 
[Bindable (true, BindingDirection.OneWay)] 
public string Username 
{
    get;
    set;
}

The attribute is now removed from the final release and its functions are taken by the Display and Editable attributes – the first one can annotate if the property should be auto-generated in the UI and the second annotates if the property should be read-only in the UI:

//The Username property can be auto-generated in the UI.
[ Display( AutoGenerateField = true ) ]
//The Username property is read only.
[ Editable( false ) ]
public string Username 
{
    get;
    set;
}

Navigation

In the Beta version of Silverlight 3 the Frame control was capable of using an UriMapper, but with the problem that the UriMapper resource should have had the ”uriMapper” name. It also was not set directly to the Frame control - it was used indirectly from the resources. Now the Frame control exposes an UriMapper property that is of type UriMapperBase. You are able to explicitly declare and specify an UriMapper for your Frame control:

<UserControl.Resources>
    <navigationCore:UriMapper x:Key="MyUriMapper">
        <navigationCore:UriMapping Uri="Home"
                                   MappedUri="/Views/Home.xaml" />
        <navigationCore:UriMapping Uri="News"
                                   MappedUri="/Views/Items.xaml?type=news" />
        <navigationCore:UriMapping Uri="Articles"
                                   MappedUri="/Views/Items.xaml?type=article" />
    </navigationCore:UriMapper>
</UserControl.Resources>
...
<navigation:Frame x:Name="MyFrame"
                          UriMapper="{StaticResource MyUriMapper}" />

Another change is that the Frame control can now navigate only to XAML pages of type Page or of a type that derives from Page.

OpenFileDialog

The ShowDialog() method of the OpenFileDialog can now only be called during user initiated events such as MouseLeftButtonUp and –Down, KeyUp and –Down, Button Click and etc. This is made of security reasons and means to make Silverlight behave like most of the browsers and plug-ins.

Silverlight responds to the Browser Zoom

Old and new Silverlight application will be able to handle the Browser Zoom. The applications will zoom by default, but you can implement a custom behavior by handling the Resized event of the application. Also there are two more ways to customize the application’s behavior when zooming:

  1. Via the System.Windows.Iterop.Content class, which is usually used as App.Current.Host.Content. The class fires a Zoomed event and has a ZoomFactor property.
    public App()
    {
        ...
        this.Host.Content.Zoomed += this.Content_Zoomed;
        ...
    }
    ...
    private void Content_Zoomed( object sender, EventArgs e )
    {
        //Implement code that should be called when the application gets zoomed.
    }
  2. By setting the EnableAutoZoom parameter of the Silverlight plugin.
    <object data="data:application/x-silverlight-2," type="application/x-silverlight-2"
    width="100%" height="100%">
        ...
        <param name="EnableAutoZoom" value="false" />
        ...
    </object>

.NET RIA Services with a new release

The new July 2009 version of the .NET RIA Services is fully compatible with the Silverlight 3 RTW. Besides the number of goodies the framework offers, the big surprise is that it is now under the Go-Live license. Let the deployment of .NET RIA Applications begin! :)

Text rendering

The so long waited ClearType for Silverlight is now a fact, so enjoy reading in Silverlight 3! :)

Summary

As I mentioned before, the list of changes is pretty long and there are some that are breaking for the Silverlight 2 applications and some that are breaking for the Silverlight 3 Beta applications. In this article I have overviewed only the most interesting ones (in my opinion), but I am sure you are eager to find out more about the other Silverlight 3 breaking changes. So read carefully the breaking changes document provided by the Silverlight SDK team, especially if you are up to convert your old Silverlight 2 or new Silverlight 3 Beat applications to the official Silverlight 3 release.


Subscribe

Comments

  • -_-

    Locally installed Silverlight 3 Beta apps - remove them before removing the Beta


    posted by Stevematt on Jul 12, 2009 21:52
    Before you remove your Silverlight 3 Beta dev environment make sure that you have uninstalled any Silverlight 3 Beta  programs that you installed on your local PC.  I.E on the desktop.  You will not be able to remove them once you install the new Silverlight 3 release.  They will not work with the new Silverlight 3 release.
  • MisterFantastic

    RE: Silverlight 3 RTW overview


    posted by MisterFantastic on Jul 16, 2009 09:57

    Fantastic Article. It would be nice if the migration from Silverlight 2 to 3 is painless. Something should be done for that.

     

    Thanks,

    Thani    

Add Comment

Login to comment:
  *      *