Porting from WPF to Silverlight: The Missing Pieces, Part 2

September 23, 2010

I bring you the sequel for the post found here.

These are just more Silverlight 3 missing features I’ve needed while porting a WPF 3.5 application to Silverlight.

So, without further ado:

Style Setter Doesn’t Support Bindings

Description: in Silverlight 3, a style setter can’t set a value to a binding.

Solution by: David Anson



In a nutshell:

Instead of writing:

<Setter Property="IsSelected" Value="{Binding IsSelected}"/>

Use the code in the post and write:

<Setter Property="common:SetterValueBindingHelper.PropertyBinding">
               Binding="{Binding IsSelected}"

The code seems completely different but it is just cosmetics, it works as advertised.


Binding Only Works On FrameworkElement Derived Classes

Description: In Silverlight 3, binding only works on classes that derive from FrameworkElement, where in WPF it works on every DependencyObject.

Solution by: Morten Nielsen


In a nutshell:

Instead of writing:

    <Image.RenderTransform >
        <RotateTransform Angle="{Binding Path=Heading}" />

Use the code in the post and write:

<Image local:SurrogateBinder.Angle="{Binding Path=Heading}">
    <Image.RenderTransform >
        <RotateTransform />


Template.FindName Doesn’t Exist

Description: Silverlight 3 doesn’t support the FindName function.

Solution by: Bea Stollnitz


In a nutshell:

Instead of writing:

_panel = Template.FindName("PART_PANEL", this) as StackPanel;

Use the code in the post and write:

_panel = TreeHelper.FindDescendent(this, "PART_PANEL") as StackPanel;

Note: Bea has some more excellent tips for porting WPF to SL in this post.


No UniformGrid

Description: Silverlight 3 doesn’t have the UniformGrid control.

Solution by: Jeff Wilcox


In a nutshell:

Instead of writing:

<UniformGrid Columns="2">

Use the code in the post and write:

<local:UniformGrid Columns="2">


That’s it for now,
Arik Poznanski.

Add comment
facebook linkedin twitter email

Leave a Reply

one comment

  1. Ralph ThompsonOctober 18, 2010 ב 07:50

    great post thanks