RIA Development Center
FeaturesTipsEventsVideosSilverlight GallerySilverlight Hosting Resources
Brad Abrams gives a brief overview of what Microsoft .NET RIA Services is and how it's going to make your life simpler. Read more
See more tips
Which platform do you use most often?
(Check one)
AIR
AJAX
Flash
JavaFX
Silverlight
Other

View Results
Get regular email alerts when we publish new features!
DevX RIA Development Update

More Newsletters
Extending Silverlight to WPF (and Vice-Versa) (cont'd)

WPF and Silverlight Feature Comparison

While Silverlight is largely a subset of WPF, there are a few features in Silverlight which are not (yet) present in WPF. Moreover, there are also a number of features present in both technologies that are implemented in somewhat different fashions. Christopher Vigna of Vertigo Software has graciously permitted me to use the following diagram which visually illustrates this point.

Figure 1. WPF & Silverlight Compatibility Diagram (as of Feb. 2009). The set of features, which includes Dependency Properties, Style and Visual Tree are present in both technologies but with differing implementations.

There is no shortage of blog articles or forum comments on WPF and Silverlight differences. However, since both Silverlight and WPF are in a state of continuous development, it would be highly unreliable to examine various lists of differences in features from a collection of blog articles since there is a great likelihood that many, if not all, of these articles will be out of date at the time that you read them. The most authoritative source for a list of these differences would be the online MSDN® help files. While this too could be out of date, it nevertheless stands a good chance of being the most comprehensive, accurate and current source of information on this topic.

Nonetheless, it's still useful to examine the current differences between Silverlight and WPF, not only to show how to handle the two of them programmatically, but also to show where the capabilities of the two might merge in the future.

Data Binding
Data Binding is one of the most impressive features of WPF. Silverlight 2 supports a subset of the Data Binding structure with some important exceptions. For example, Silverlight does not support binding one UI element to another UI element as in the canonical WPF example of a Slider bound to a TextBox or TextBlock. Instead, Silverlight is limited to binding UI elements to standard .NET objects such as a numeric variable (e.g. binding a TextBlock to the time of day). Silverlight also does not support binding directly to XML data as can be done in WPF via an XmlDataProvider.

This does not mean that it is impossible in Silverlight to link the value of some property on one UI element to the value of some other property on a different UI element, but only that it cannot be done via Data Binding. To achieve this linkage in Silverlight requires a developer to write his own event handlers. While not as convenient as Data Binding, WPF also supports the event handler approach.

For an excellent detailed explanation of Silverlight Data Binding, I recommend this tutorial by Jesse Liberty and Tim Heuer.

It is also important to appreciate that even when both Silverlight and WPF contain the same class, that does not mean that both classes share all the same members. For example, the following screenshots illustrate how there are many more properties in the WPF version of the Binding class than in the equivalent Silverlight class. The principal explanation for these differences is the desire to maintain the smallest possible file size for the Silverlight browser plug-in. The absence of certain of these properties in the Silverlight version, for example the ElementName property, explains why it is not possible to bind UI elements to other UI elements in Silverlight when that capability is present in WPF.

Figure 2. List of Properties for the WPF Binding Class.

Figure 3. List of Properties for the Silverlight Binding Class.
Triggers

Triggers in WPF have proved to be very useful for starting and stopping Animations. Unfortunately, however, triggers are largely absent from Silverlight. Silverlight only supports EventTriggers and then only for the Loaded event and the BeginStoryboard action. Since one of the primary features of both WPF and Silverlight is the support for Animations, the absence of Triggers in Silverlight can have a significant impact on those applications which rely heavily on Animations.

To some extent, the absence of Triggers in Silverlight can be mitigated through the use of the VisualStateManager. Microsoft does plan to port the VisualStateManager to WPF. Once that happens, joint Silverlight/WPF development or application conversion will become easier.

Control Support
At present, WPF includes far more controls than Silverlight. Notable omissions from Silverlight include the FlowDocument, ToolBar, ListView, Menu, Context Menu and Ribbon controls. The MSDN Help Files include a comprehensive list detailing which controls are supported in WPF or Silverlight or both.

Control development for Silverlight is proceeding apace, however, as can be seen at the CodePlex site for the Silverlight Toolkit. This website reflects Microsoft's new development strategy regarding Silverlight controls which are now open source and available to developers from early beta stages. At present, there are approximately a dozen new controls for Silverlight in development working their way toward final release. For a comprehensive description of the Silverlight Toolkit, see my earlier article on this topic.

3D Graphics
3D graphics are not yet all that commonplace in WPF but at least support for it is available. Silverlight, by comparison, does not yet support 3D graphics.
Previous Page: Sorting Out Scenarios Next Page: Advance Planning Your Application
Page 1: Sorting Out ScenariosPage 3: Advance Planning Your Application
Page 2: WPF and Silverlight Feature Comparison 
Rate This Content:
Low     High
4 after 5 ratings