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(GetTop.Count);
double Top = GetTop[ran];
double Left = GetLeft[ran];
Canvas.SetTop(myImg, Top);
Canvas.SetLeft(myImg, Left);
GetTop.Remove(Top);
GetLeft.Remove(Left);
}
the Images don't change places one box with another as intended. Some Images are lost and it doesn't Show them. Any Idea?