开发者

How to move an object in x y (diagnoal) direction in Silverlight C#

i want to move an canvas in diagonal direction when i tried to TranslateTransform in xaml it works but from code behind it is not working

<Canvas.RenderTransform>
   <TranslateTransform X="1" Y ="1"/>
</Canvas.RenderTransform>

code:-

public void AnimateTo(Canvas c)
{
        // update the value
     开发者_Python百科   TranslateTransform translate = c.RenderTransform as TranslateTransform;
        translate.Y = --x;
        translate.X = --y;
}

Can some one help me


You cannot access the RenderTransform this way in code. Set a name to your TranslateTransform tag like this :

<Canvas.RenderTransform>
    <TranslateTransform x:Name="myCanvasTranslate" X="1" Y ="1"/>
</Canvas.RenderTransform>

then in code, use :

myCanvasTranslate.X++;

myCanvasTranslate.Y++;

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜