Silverlight binding to TranslateX

I have a simple winphone7 application, but I think this applies to any Silverlight.

I basically have an ellipse, and I would like to move it using the X and Y properties for translation. Here is my attempt:

<Ellipse Fill="#FFF4F4F5" Margin="0,0,-3,-3" Stroke="Black" RenderTransformOrigin="0.5,0.5" > <Ellipse.RenderTransform> <CompositeTransform TranslateY="{Binding Y}" TranslateX="{Binding X}"/> </Ellipse.RenderTransform> </Ellipse> 

I am sure that the binding is set correctly; The problem is that this gives me this error when starting the application:

2260 An error has occurred. [Line: 4 Position: 33]

which is a XAML error. The error is skipped when I comment out the composittransform line.

Can someone point me in the right direction? If you need more code, let me know, I will post more.

thanks

+4
source share
1 answer

Windows Phone 7 is currently based on Silverlight 3, not Silverlight 4.

One limitation in Silverlight 3 is that you can only bind to an element that derives from FrameworkElement . Transformation classes are not derived from FrameworkElement and therefore cannot participate in bindings.

Instead of moving an ellipse through a snap, consider using a Storyboard to animate a transformation.

+5
source

Source: https://habr.com/ru/post/1312006/


All Articles