Silverlight 5: Some New Features For Developers

Abstract: Silverlight 5, the latest version of Microsoft's browser plug-in comes with significant improvements with respect to Controls, Text, Dialog, Performance and data-binding. In this article, we will take an overview of some of the new Silverlight 5 features.

Silverlight 5, the latest version of Microsoft's browser plug-in was made available in December 2011. I have been working on it ever since and also consulting my clients about the new changes in Silverlight 5 with respect to Controls, Text, Dialog and of course about data-binding. I thought of discussing some of the new Silverlight 5 features with you with the help of some examples.

Silverlight 5 comes with the following feature list (not comprehensive):

New Controls

Text Control Changes

Databinding Improvements

Performance Improvements

XAML Changes

User Interface Changes

Graphics Changes

Media Changes

In this article, I am going to walk you through some New Controls, Text Control Changes, and Databinding improvements. I have explained some simple but important features that can be used for developing UI and for any Silverlight 5 based LOB applications.

New Controls

Silverlight 5 provides new controls like the PivotViewer for developers which can handle and display large amounts of data at a given instance. One of the best uses of this control is that, an end-user can now easily search the information he needs from the source collection. This control provides property types like:

PivotProperties:

PivotViewerStringProperty : Used to bind string data from source.

PivotViewerDateTimeProperty: Used to bind DateTime property from source

Step 3: Run the application and you should see a result similar to the following:

Under the studentId on the left, click 1. The result will be as shown below:

Using the PivotViewer Control, the end-user has more control on filtering data from the source collection.

ItemsControl Text Search improvements

Controls like the ListBox, ComboBox are more frequently used to display collection data. Now if the end-user wants to search any specific matching date element from any of these ItemsControls, he/she needs to scroll down all the way which is time consuming and does not provide a good user experience. In Silverlight 5, an attached property ‘TextPath’ is provided which you can set against any property of the source collection. Now the end-user can click on any data element inside the ListBox and by using the keyboard keys, the data element matching to the specific character can be found.

Step 4: Run the application and you will should see some Data in ListBox. Click on the first value of the ListBox and press any alphabet from the keyboard, the first data value matching the first character will be selected as shown below:

DialogBox improvements

Silverlight applications allow us to create a file and save it on local disk. It also allows us to open the file from the local store. To do this, we have been provided with ‘openFileDialog’ and ‘SaveFileDialog’ classes. OpenFIleDialog by default opens the documents and settings (user specific folder) whereas SaveFileDialog allows us to save file of any extension. In Silverlight 5, OpenFileDialog has introduced a new property called ‘InitialDictionary’ using which you can specify a default path. Similarly by setting the ‘DefaultFileName’ property of the SaveFileDialog, you can specify a default file name that gets created when user wants to save data locally from the Silverlight application. It’s a simple feature, but very useful!

Example:

Create a Silverlight 5 application and add the following two buttons on the MainPage.Xaml as shown here:

Text Control Changes

Character Spacing:

In Silverlight 5, controls like TextBox and TextBlock provide the ‘CharacterSpacing’ feature. This provides a mechanism to increase and/or decrease characters spacing in the entered text. The distance between the characters is calculated based upon 1000th of the font size. E.g. if the FontSize is 50 pixels and CharacterSpecing is set to 200, the distance between two characters will be (50*200/1000=10 pixels).

Here for the TextBox and TextBlock, the CharacterSpacing is set to 200 and the FontSize is 50, now if you run the application, the result will be as shown below:

Databinding Basic changes

There are many features introduced in databinding. One of them is you can directly apply a breakpoint on the Binding Expression on XAML and using the local window, you can see the bound object data:

Performance

One of the most exciting features is the improved performance for Silverlight 5 applications. Now SL 5 applications support native 64 bit browsers which is a big boost to consuming large amount of data. The XAML parser has been improved for parsing User Controls and resource dictionaries where style and other UI effects are declared. Significant improvements have been made while booting apps, so now it takes less time to start-up Silverlight applications. There have also been some significant improvements on hardware acceleration, text rendering quality and animation quality

Mahesh is having 10 years of experience in IT education and development. He is a Microsoft Certified Trainer (MCT) since 2005 and has conducted various Corporate Training programs for .NET Technologies (all versions). Follow him on twitter @maheshdotnet

User Feedback

Comment posted by
sachin nimbalkar
on Tuesday, May 22, 2012 11:55 PM

The examples shown in these article are good and made me feel more confident in the understating new features of SL 5.0

Comment posted by
Yurov
on Wednesday, May 23, 2012 7:53 AM

thanks for the feature round up. seems like silverlight is ALIVE

Comment posted by
silverlight is
on Monday, December 17, 2012 3:50 AM

Tuesday, May 22, 2012 11:55 PM

Comment posted by
abirami
on Saturday, February 9, 2013 6:08 PM

useful to me

Comment posted by
Do we have menu control in Silverlight ?
on Wednesday, August 14, 2013 3:13 PM

Microsoft did not implement Menu control in the earlier versions. Is it there in the current version ?