namespace WPFMatchPair.View { /// <summary> /// Interaction logic for FourWindow.xaml /// </summary> public partial class FourWindow : Window { ShuffleMethods shuffleMethods = new ShuffleMethods(); int boardSize = (4 * 4); public FourWindow() { InitializeComponent(); string[] pictureArray = shuffleMethods.NewWindowPictures(ImageDataBase.availablePictures, boardSize)!; Label label = new(); if (pictureArray != null) { for (int i = 0; i < boardSize; i++) { label = (Label)FindName($"label{i + 1}"); label.Content = pictureArray[i]; //label.SetValue(ContentProperty, pictureArray[i]); } } else MessageBox.Show("Failed to generate picture array."); /*Label label = (Label)FindName($"label1"); label.Content = "\U0001F680"; label = (Label)FindName($"label2"); label.Content = "\U0001F99E";*/ } private void Restart_Click(object sender, RoutedEventArgs e) { shuffleMethods.ResetWindow(boardSize); } private void Exit_Click(object sender, RoutedEventArgs e) { Close(); } } }
fix invalid code: