This is my code below in an event button click handler. Whenever I click once it will randomize the images. Is there a possible solution for my code to loop once instead of infinite times looping while clicking.
I am doing a picture matching memory game, so therefore it keep randomizing while i click the button.
shuffled01 = dict01.Shuffle();
void btn_Click(object sender, EventArgs e)
{
foreach (var a in shuffled01)
{
button.Name = "a" + a.Key.ToString();
button.MinHeight = 100;
button.MinWidth = 100;
// button.Name = "a" + a.Key.ToString();
ImageBrush brush = new ImageBrush();
BitmapImage bitmap = new BitmapImage();
button.Background = brush;
bitmap.BeginInit();
bitmap.UriSource = new Uri(@"C:\inetpub\wwwroot\istellar 22-10-13\iStellarMobile\iStellarMobile\"
+ a.Value.ToString().Substring(1), UriKind.Absolute);
bitmap.ToString();
bitmap.EndInit();
brush.ImageSource = bitmap;
}
}
Thanks in advance.