DCSIMG
Porting from WPF to Silverlight: The Missing Pieces, Part 2 - Arik Poznanski's Blog

Arik Poznanski's Blog

It CAN be done with .NET

News

MVP

MCC

CodeProject MVP

MCPD

MCTS

Subscribe to my blog by email

Arik Poznanski LinkedIn Profile

Email: arik.com at gmail dot com
or, use this form

Locations of visitors to this page


Sela Group

Sela Canada

DZone MVB

Links

Official Blogs

WPF / SL Blogs

Developers Blogs

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

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

http://blogs.msdn.com/b/delay/archive/2009/05/07/one-more-platform-difference-more-or-less-tamed-settervaluebindinghelper-makes-silverlight-setters-better.aspx

http://blogs.msdn.com/b/delay/archive/2009/11/02/as-the-platform-evolves-so-do-the-workarounds-better-settervaluebindinghelper-makes-silverlight-setters-better-er.aspx

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">
    <Setter.Value>
        <common:SetterValueBindingHelper>
            <common:SetterValueBindingHelper
               Property="IsSelected"
               Binding="{Binding IsSelected}"
               />
        </common:SetterValueBindingHelper>
    </Setter.Value>
</Setter>

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

http://www.sharpgis.net/post/2009/05/04/Using-surrogate-binders-in-Silverlight.aspx

In a nutshell:

Instead of writing:

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

Use the code in the post and write:

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

 

Template.FindName Doesn’t Exist

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

Solution by: Bea Stollnitz

http://bea.stollnitz.com/blog/?p=366

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

http://www.jeff.wilcox.name/2009/01/uniform-grid/

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.

Comments

DotNetKicks.com said:

You've been kicked (a good thing) - Trackback from DotNetKicks.com

# September 23, 2010 12:59 PM

Twitter Trackbacks for Porting from WPF to Silverlight: The Missing Pieces, Part 2 - Arik Poznanski's Blog [microsoft.co.il] on Topsy.com said:

Pingback from  Twitter Trackbacks for                 Porting from WPF to Silverlight: The Missing Pieces, Part 2 - Arik Poznanski's Blog         [microsoft.co.il]        on Topsy.com

# September 24, 2010 6:30 PM

Lester's WPF\Silverlight Blog said:

The other day when browsing through the blogosphere I came across Arik's posts describing the workarounds

# September 27, 2010 5:56 PM

Ralph Thompson said:

great post thanks

# October 18, 2010 7:50 AM

Arik Poznanski's Blog said:

Yesterday I’ve delivered my lecture titled “ 3-Screens Development using WPF, SL and WP7 ” in the SDP

# March 16, 2011 1:59 PM

Arik Poznanski's Blog said:

Yesterday I’ve delivered my lecture titled “ 3-Screens Development using WPF, SL and WP7 ” in the SDP

# March 16, 2011 6:49 PM

Porting WPF apps to Silverlight « Mas-Tool's Favorites said:

Pingback from  Porting WPF apps to Silverlight &laquo;  Mas-Tool&#039;s Favorites

# August 5, 2011 9:38 AM

Dmitry Shechtman 2.0 said:

Silverlight 5 RC is available for download (Yes, I know, I&#39;m a little late ). Silverlight 5 introduces

# September 3, 2011 3:21 PM

Dmitry Shechtman 2.0 said:

Silverlight 5 RC is available for download (Yes, I know, I&#39;m a little late ). Silverlight 5 introduces

# September 3, 2011 3:21 PM

Arik Poznanski's Blog said:

I feel this is a good time for me to present a summary of some of the posts I wrote.. Most Interesting

# November 20, 2011 12:13 AM

Arik Poznanski's Blog said:

I feel this is a good time for me to present a summary of some of the posts I wrote.. Most Interesting

# November 20, 2011 12:14 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 


Enter the numbers above: