lundi 18 mai 2015

Canvas Image Shuffle

So I have a Canvas and a set of 18 Images in it and I want to shuffle the Images

 foreach (var myImg in GameCanvas.Children.OfType<Image>())
        {
            GetTop.Add(Canvas.GetTop(myImg));
            GetLeft.Add(Canvas.GetLeft(myImg));
            listNum++;
            myImg.IsTapEnabled = false;
        }

I have this part to add the Top and Left of each image in a separate list BUT when I try this

foreach (var myImg in GameCanvas.Children.OfType<Image>())
        {
            int ran = rand.Next(0, listNum);
            Canvas.SetTop(myImg, GetTop[ran]);
            Canvas.SetLeft(myImg, GetLeft[ran]);
        }

the Images don't change places one box with another as intended. Any Idea? I am working on a Universal App




Aucun commentaire:

Enregistrer un commentaire