private void addPersonsButton_Click(object sender, RoutedEventArgs e) { AddPersonsToMaterialWindow addPersonsToMaterialWindow1 = new AddPersonsToMaterialWindow(); addPersonsToMaterialWindow1.ShowDialog(); if (addPersonsToMaterialWindow1.MyDialogResult == true) { Person p; int t; for (int i = 0; i < addPersonsToMaterialWindow1.SelectedPersonIdList.Count; i++) { t = addPersonsToMaterialWindow1.SelectedPersonIdList[i]; p = model1.Persons.First(o => o.Id == t); PersonsToAdd.Add(p); } } }