Anyone know if it’s possible to databind the ScaleX and ScaleY of a render transform in Silverlight 2 Beta 2? Binding transforms is possible in WPF – But I’m getting an error when setting up my binding in Silverlight through XAML. Perhaps it’s possible to do it through code?
<Image Height='60' HorizontalAlignment='Right' Margin='0,122,11,0' VerticalAlignment='Top' Width='60' Source='Images/Fish128x128.png' Stretch='Fill' RenderTransformOrigin='0.5,0.5' x:Name='fishImage'> <Image.RenderTransform> <TransformGroup> <ScaleTransform ScaleX='1' ScaleY='1'/> <SkewTransform/> <RotateTransform/> <TranslateTransform/> </TransformGroup> </Image.RenderTransform> </Image>
I want to bind the ScaleX and ScaleY of the ScaleTransform element.
I’m getting a runtime error when I try to bind against a double property on my data context:
Message='AG_E_PARSER_BAD_PROPERTY_VALUE [Line: 1570 Position: 108]'
My binding looks like this:
<ScaleTransform ScaleX='{Binding Path=SelectedDive.Visibility}' ScaleY='{Binding Path=SelectedDive.Visibility}'/>
I have triple verified that the binding path is correct – I’m binding a slidebar against the same value and that works just fine…
Visibility is of type double and is a number between 0.0 and 30.0. I have a value converter that scales that number down to 0.5 and 1 – I want to scale the size of the fish depending on the clarity of the water. So I don’t think it’s a problem with the type I’m binding against…
ScaleTransform doesn’t have a data context so most likely the binding is looking for SelectedDive.Visibility off it’s self and not finding it. There is much in Silverlight xaml and databinding that is different from WPF…
Anyway to solve this you will want to set up the binding in code**, or manually listen for the PropertyChanged event of your data object and set the Scale in code behind.
I would choose the latter if you wanted to do an animation/storyboard for the scale change.
** i need to check but you may not be able to bind to it. as i recall if the RenderTransform is not part of an animation it gets turned into a matrix transform and all bets are off.