public SaveBDDWindow(Activity activity, Teacher teacher) { InitializeComponent(); this.activity = activity; classes = new List <Class>(); BDDAccess bddAccess = new BDDAccess(); if (bddAccess.Connect()) { classes = bddAccess.GetClasses(); TeacherNameTextBox.Text = teacher.FirstName + " " + teacher.LastName; foreach (var classe in classes) { ClassesListBox.Items.Add(new CheckBox() { Content = classe.ClassName }); } ActivityNameTextBox.Text = activity.ActivityName; VisibilityCheckBox.IsChecked = activity.ActivityVisibility; foreach (var classe in activity.Classes) { foreach (CheckBox listBoxItem in ClassesListBox.Items) { if (listBoxItem.Content.ToString().Equals(classe.ClassName, StringComparison.CurrentCultureIgnoreCase)) { listBoxItem.IsChecked = true; } } } } else { MessageBox.Show(bddAccess.Information, new AssemblyInformations(Assembly.GetExecutingAssembly().GetName().Name).Product, MessageBoxButton.OK, bddAccess.MessageBoxImage, MessageBoxResult.OK); Close(); } }