Search code examples
wpfellipseuielement

RenderTranform not render transforming


So I have a canvas and a Ellipse on it . And call a method to mote the Ellipse around like so

public void moveElipse1ToCoordinate(Point point)
    {
        Action action = () =>
        {
           TranslateTransform moveTo = new TranslateTransform();
            moveTo.X = point.X;  
            moveTo.Y = point.Y;
            StimulyEllipse1.RenderTransform = moveTo;
        };
        Dispatcher.BeginInvoke(action);
    }

And I use this function in a for loop .

for(int i=0 ; i<=1000; i++)
moveElipse1ToCoordinate(new Point(i,i)

Both X and Y coordinates are constantly between 0 and 1000 , the size of the canvas . Yet the Ellipse is not shown at all .

What am I missing from this call ?


Solution

  • If you want it to move smoothly, as an animation, you'll need to use the animation classes specifically. The UI won't update until the loop has completed (and with an X,Y of the size of the canvas, the ellipse would appear below and to the right of the total canvas).