private void DisplayPicture(object sender, SelectionChangedEventArgs e) { // Gets a path from the imageArray by referring to the selected index in the listbox and adds it in the imageGrid if (pictureListBox.SelectedIndex != -1) { imageGrid.Children.Clear(); Image currentImage = ShopUtils.CreateImage("SampleImages/" + imageArray[pictureListBox.SelectedIndex], true); imageGrid.Children.Add(currentImage); } }