Best way to move an image across part of the screen?

Posted by rushonerok on Stack Overflow See other posts from Stack Overflow or by rushonerok
Published on 2011-01-01T20:59:15Z Indexed on 2011/01/01 21:53 UTC
Read the original article Hit count: 216

I have a Silverlight WP7 app and an image on my page that I want to appear to slide across the screen. What is the best way of doing this? I wrote this real quick but the UI doesn't update until the entire method is done.

    private void SpinImg(Image img, double left) {
        for(int i = 1; i <= 10000; i++) {
            img.Margin = new Thickness(left, img.Margin.Top + 1, 0, 0);
            if(img.Margin.Top > 314) {
                //move it to the top
                img.Margin = new Thickness(left, -105, 0, 0);
            }
            int wait = 1000 / i;
            Thread.Sleep(wait);
        }
    }

© Stack Overflow or respective owner

Related posts about c#

Related posts about silverlight-4.0