views:

162

answers:

2

Hi,

I need to zoom Canvas. In WPF it is possible to bind ScaleTransformation.X to slider.Value.

I'm not able to do the same in Silverlight - some errors.

Is it supported in SL3?

Thank you.

A: 

The reason this doesn't work is that in SL3 the binding target needs to be a FrameworkElement. (This restriction is lifted in SL4 but that doesn't help right now).

However the solution just takes a little lateral thinking (or in this case backward thinking). The source object does not need to be a Framework element. So the answer is reverse the binding, that is put the binding on the Slider Value property and put it in to TwoWay mode.

<Border Width="200" Height="200">
 <Border.RenderTransform>
  <ScaleTransform x:Name="TargetTransform" />
 </Border.RenderTransform>
 <!-- Some Content Here -->
</Border>

<Slider Value="{Binding ScaleX, ElementName=TargetTransform, Mode=TwoWay}"
 Width="200" Canvas.Top="250" 
 Minimum="0.1" Maximum="2.0" />
AnthonyWJones