Silverlight 4.0 Features


This article describes the enhanced and new features of Silverlight 4.0

Silverlight 4.0 Features


Enhancement Areas


Enhanced Features

  1. Fluid UI: In order to support more fluid user interface experiences, new states have been added to ItemsControl. These new states: BeforeLoaded, Loaded and Unloaded help animate the transition of contents between states in an ItemsControl and provide a more interactive and "fluid" experience to the user.

  2. Full Screen Keyboard Access: If you are developing kiosk applications or other Silverlight applications that run in full-screen mode (IsFullScreen="true"), you have noticed that only a limited set of keyboard input was enabled. In Silverlight 4 trusted applications, any application in full-screen mode can have full keyboard input for things like TextBox or other input controls. This only applies to trusted applications.

  3. More Trust Applications: One thing users have been asking for is to enable Silverlight out-of-browser (OOB) applications to have more privileges. You can now alter the OOB manifest to request more elevated permissions for your application. Using Visual Studio you can look at the project properties and enable the checkbox to add this request:
    elevated trust
    The result is that the OOB install dialog now looks a little different and warns the user of these elevated privileges:
    security warning
    It is important to note that this trusted application request still does not involve installing any additional runtime for the use. It is a part of the Silverlight 4 runtime – no additional download/framework would be required.

  4. Data Binding:
    • IDataErrorInfo and asynchronous validation: Silverlight adds the IDataErrorInfo interface enables the reporting of validation errors that a user interface can bind to. When an entity implements this interface and the entity is involved in a binding operation, it invokes the indexer to validate the properties. The bound target properties in the UI will receive the error messages and display the validation states if the ValidatesOnDataErrors property is set to true. IDataErrorInfo is limited to validating on a per property basis. However, Silverlight 4 also adds the INotifyDataErrorInfo interface that allows validation across properties of an entity. It also allows entity objects to enable notification of data errors in the UI. INotifyDataErrorInfo allows developers to provide custom, asynchronous validation support to access server-side validation logic. It exposes a HasErrors property to indicate if there are any errors and has a GetErrors method to retrieve the errors. The ErrorsChanged event is raised when new errors are added. If the binding property ValidatesOnNotifyDataErrors is set to true and the source object implements the interface, the binding engine in Silverlight will listen for the ErrorsChanged event.

    • DependencyObject Binding: Silverlight introduces the ability to bind properties on a DependencyObject (DO) and not just on FrameworkElements. For example, in Silverlight you can bind the rotation angle of a RotateTransform to a Slider control.
      Sample Code:

      <Rectangle Width="100" Height="100"
      RenderTransformOrigin="0.5, 0.5" Background="#FF2B6092">
      <Rectangle.RenderTransform>
      <RotateTransform Angle="{Binding ElementName=slider, Path=Value}" />
      </Rectangle.RenderTransform>
      </Rectangle >
      <Slider x:Name="slider" Height="20" Margin="0,225,0,55" Minimum="0"
      Maximum="360" />

    • StringFormat, TargetNullValue, and FallbackValue: If you've ever done databinding in XAML using simple things like currency, dates, etc. then you have likely created a ValueConverter. While for simple things it is not difficult, it was often a tedious and repetitive task. StringFormat is now available to you for a simpler solution for XAML databinding and formatting the output.
      Sample Code:

      <TextBox Text="{Binding Path=PublishedDate, Mode=OneWay, StringFormat='MM-dd-yyyy'}"/>

      Additionally, you can also specify Fallback and TargetNull values in your binding syntax:

      <TextBox Text="{Binding Path=SomeBindingValue, Mode=TwoWay, FallbackValue=N/A}" />
      <TextBox Text="{Binding Path=QuantityOnHand, Mode=TwoWay, TargetNullValue=0}" />

      The FallbackValue displays a value when the binding operation is unsuccessful, where the TargetNullValue helps provide a value when the result of the binding value is NULL.



  5. New Features


    New Features

    1. Tooling: With Visual Studio 2010, you finally have designer surface back for Silverlight! Yes, you have an editable design surface for Silverlight, and actually this isn’t just limited to Silverlight 4. It is available for Silverlight 3 as well. What is great about the Silverlight tools in VS2010 is that the databinding support is pretty rich in the designer surface as well.

    2. Print API: One of the top-most requested features in Silverlight has been to enable some printing support from the Silverlight application client-side versus always having the developer do things server-side. In Silverlight 4, a printing API is provided that is extensible for the developer and provide you with a simple printing of a visual tree, or a highly extensible model to enable you to create a virtual visual tree to print for the end user directly from Silverlight.

    3. Right Click Event Handling: Do you have an application that has a need for a context-style menu (aka ‘right click’ menus)? Well, in addition to the MouseLeftButtonUp/Down events, you now have the MouseRightButtonUp/Down events for you to attach to and handle. This enables the developer to take control over what you’d like to do when those events occur. This can be from handling simple commands for gaming (i.e., a right click is a different interaction in the game than the left click) or as well for providing context-style menus for additional functionality within the application. Here’s an sample output of ‘right click’ menu:
      right click

    4. Local File Access: In order to read/write data to the user’s machine, you normally have to do it through a mechanism like OpenFileDialog (read) and SaveFileDialog (write). In Silverlight 4 you can now have direct local file access to the users’ "My” folders in their profile. These are things like MyDocuments, MyVideos, MyMusic, etc. On OSX platform these map to the same user-level profile folders like /users/timheuer/Videos. You use the Environment namespace to get the path locations for the operation you are wishing to do. This feature requires a trusted application (elevated permissions).

    5. COM interoperability: Have you had the need to interoperate with device peripherals that only expose a COM interface? What about having your Silverlight application talk with Office applications? Using the ComAutomationFactory API, you can now have your Silverlight application instantiate and interact with COM applications on the Windows client.

    6. Notification (aka “toast”) API: Notification mechanism is often referred to as “toast” where a subtle notification temporarily displays in the user’s screen providing some information provided by the application. Perhaps one of the more common uses of this is in mail applications, like Outlook; where new mail notifications pop-up message notification windows near the system tray in Windows. By using the NotificationWindow in Silverlight, you can provide a simple or customized notification mechanism for your application. Here’s an example of a styled NotificationWindow content:
      Notification Window

    7. Text Trimming: The TextBlock control has a new property called TextTrimming that enables you to use the WordElipse trimming value. When the property is set, any text exceeding the visible limit of the control will be truncated and an ellipsis will be displayed to the user indicating more content.
      Sample Code:

      <TextBlock HorizontalAlignment="Left" VerticalAlignment="Top"
      Text="The quick brown fox jumped over the tall white fence"
      TextTrimming="WordEllipsis" Width="120" />

      Sample Output:
      Text Trimming

    8. Right-to-left support in controls: If you are writing an application that requires right-to-left (RTL) support in either text and/or controls, a new attribute for UIElement is now provided for you. The FlowDirection attribute can be applied to represent the element in RTL format.
      Sample Code:

      <TextBlock FlowDirection="RightToLeft" Foreground="White" Text="RTL Sample" FontSize="20" Margin="20" />


    9. Google Chrome support: During this release cycle Silverlight will be officially providing support for the Google Chrome browser. Silverlight has generally worked in Chrome, but in this release Chrome will be added to official test/support matrix.

    10. Managed Extensibility Framework (MEF): Managed Extensibility Framework (MEF) means building maintainable/pluggable RIA apps just got a whole lot easier. The Managed Extensibility Framework (MEF) is a new library in Silverlight 4 for building RIAs that can be incrementally extended. With MEF you extend your apps in a declarative fashion and let MEF do the plumbing rather than writing all the plumbing code yourself.
      • It’s for you and your dev team: You can add and replace functionality to the system without having modified existing code. This means you and your QA team are happy because you don’t have to worry about introducing bugs into the existing code base.

      • It’s for your customers: MEF allows you to design applications and libraries that can be extended by third-parties after they have been deployed.

      • Always there, always ready: In Silverlight, MEF is ready to go whenever and wherever you need it. You don’t have to be an acrobat, or have a master’s degree in complexity, you just do it.



Related Articles

Using Silverlight Grid Control

The Silverlight Grid control is the most flexible layout panel, and supports arranging controls in multi-row and multi-column layouts.

More articles: Features of Silverlight 4.0 Silverlight 4.0 Data Binding Silverlight

Comments

Author: asdfg28 Apr 2010 Member Level: Gold   Points : 0

Thanks dude for sharing with us

Author: Nishikant29 Apr 2010 Member Level: Gold   Points : 0

It's my pleasure.



  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:
    Email: