first_page

My Noted Differences between Silverlight and WPF

Silverlight 4

Libraries

  • The DLL %SystemRoot%\M``icrosoft\Framework\v3.0\PresentationCore.dll is not a part of Silverlight (PresentationCore.dll can be thought of as the heart of WPF). This means that the System.Windows.* namespaces are not a part of WPF.
  • Silverlight uses %ProgramFiles%\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\System.Xml.dll (version 2.0.5.0) not the one used by managed Windows Applications (%SystemRoot%\``Microsoft.NET\Framework\v2.0.50727\System.Xml.dll). The first implication here is major: the System.Xml.XPath is missing from Silverlight 3.0 (but kind of returns in Silverlight 4!).
  • Silverlight uses %ProgramFiles%\Reference Assemblies\Microsoft\Framework\Silverlight\v3.0\``s``ystem.dll (version 2.0.5.0 in lowercase). This implies that Josh Smith’s WPF-based ViewModelBase.VerifyPropertyName() (announced on his Blog and published in his MSDN article) method does not work because the TypeDescriptor class is not in Silverlight. A Silverlight-based equivalent published by Shawn Wildermuth for MSDN works without verifying property names.
  • There is no Silverlight version of StructureMap (2.5.x). This actually makes Unity superior for the moment. Jeremy Miller is thinking about this

Visuals

  • The HyperlinkButton control is exclusively a part of Silverlight. This may be to take the place of the Hyperlink control in WPF (the Hyperlink control is defined in the System.Windows.Documents namespace—which is not a part of Silverlight 3). Silverlight, then, makes controls that derive from ButtonBase have a near monopoly on click-like events. This explains (to me) why Laurent Bugnion, author of the MVVM Light Toolkit, defines commanding extension methods (GalaSoft.MvvmLight.Command.ButtonBaseExtensions) exclusively for ButtonBase``.
  • Controls like GridSplitter are in the Silverlight 3 SDK (%ProgramFiles%``\Microsoft SDKs\Silverlight\v3.0\Libraries\Client\System.Windows.Controls.dll)—along with Calendar, DatePicker, HeaderedItemsControl, and more. By the way you might get the AG_E_UNKNOWN_ERROR because of Style Setter attributes not parsing at runtime.
  • There is no concept of a startup Window in Silverlight Navigation Applications. A root UserControl is defined instead. Silverlight places great emphasis on the concept of the “root visual” (Application.Current.RootVisual).
  • The attribute TargetType="{x:Type StackPanel}" is not supported in Silverlight (x:Type syntax is not supported). Use TargetType``="``StackPanel" instead.
  • The GridSplitter control apparently is not available for Silverlight by default. It’s in the Silverlight 3 SDK (%ProgramFiles%``\Microsoft SDKs\Silverlight\v3.0\Libraries\Client\System.Windows.Controls.dll).

Links to Selected Resources

“[WPF Compatibility](http://msdn.microsoft.com/en-us/library/cc903925%28VS.95%29.aspx)” Might be slightly out of date for Silverlight 3: “Silverlight does not support dynamic resources. All resource references to keyed resources in XAML are static. … Silverlight introduces the [VisualStateManager](http://msdn.microsoft.com/en-us/library/system.windows.visualstatemanager%28v=VS.95%29.aspx), which helps define and manage the visual behavior based on the control state. For example, "Pressed" might be defined as a button state when the button is clicked. By using [VisualStateManager](http://msdn.microsoft.com/en-us/library/system.windows.visualstatemanager%28v=VS.95%29.aspx), you can define all the control states and the transitions between states in your control templates. For more information, see [Customizing the Appearance of an Existing Control by Using a ControlTemplate](http://msdn.microsoft.com/en-us/library/cc189093%28v=VS.95%29.aspx).”
“[What features of WPF are excluded in Silverlight 3?](http://stackoverflow.com/questions/1984168/what-features-of-wpf-are-excluded-in-silverlight-3)” Links to MSDN article (see below).
“[XAML Processing Differences Between Silverlight and WPF](http://msdn.microsoft.com/en-us/library/cc917841%28VS.95%29.aspx)” “All material in this section applies specifically to Silverlight version 3 and its implementation of the XAML parser provided with that release. Also, processing XAML for the JavaScript API in Silverlight is not described here, because the JavaScript-specific XAML behaviors in Silverlight are not relevant for comparison with WPF.”
“[Control Styles and Templates](http://msdn.microsoft.com/en-us/library/cc278075%28v=VS.95%29.aspx)” Can’t find the WPF equivalent of this: “Silverlight uses default styles and templates for several controls. You can copy these styles and templates into your project and modify them in order to customize control behavior and appearance.”
“[Security Considerations for Reflection](http://msdn.microsoft.com/en-us/library/stfy7tfc%28VS.95%29.aspx)” “In Silverlight, you cannot use reflection to access private types and members. If the access level of a type or member would prevent you from accessing it in statically compiled code, you cannot access it dynamically by using reflection.”
“[Using RelayCommands in Silverlight 3 and WPF](http://blog.galasoft.ch/archive/2009/09/26/using-relaycommands-in-silverlight-and-wpf.aspx)” “In Silverlight, parts of the “plumbing” are available already (the [**ICommand**](http://msdn.microsoft.com/en-us/library/system.windows.input.icommand.aspx) interface) but most of it is missing. This led some very clever people to implement Commands in Silverlight, to replace the missing pieces by a custom implementation. In [Prism](http://compositewpf.codeplex.com/), the command implementation is called **DelegateCommand**. In my [MVVM Light Toolkit](http://www.galasoft.ch/mvvm/getstarted), I use a command that my good friend, colleague at IdentityMine and fellow WPF Disciple [Josh Smith](http://joshsmithonwpf.wordpress.com/) created, called the **RelayCommand***.*”

rasx()