开发者

Silverlight Binding to TranslateX

I have a simple winphone7 application, but I think this would apply to any silverlight.

Basically I have an ellipse and I would like to move it with the translate X and Y properties. 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 pretty sure the Binding is set correctly; The problem is it gives me this error when I run the application:

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

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

开发者_开发知识库

Can anyone point me in a right direction? If you need more code let me know, i'll post more up.

Thanks


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

One of the limitations in Silverlight 3 is that you can only bind to an element that derives from FrameworkElement. The transform classes do not derive from FrameworkElement and hence cannot participate in binding.

Instead of moving the ellipse via binding consider using a Storyboard to animate the transform instead.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜