public AddChildWindow(string firstName, string lastName) { InitializeComponent(); txtFirstName.Text = firstName.Trim(); txtLastName.Text = lastName.Trim(); var familyList = VakacientjesDb.GetFamilies(); foreach (Family family in familyList) { cmbFamily.Items.Add(family.Name); } }
private void BtnAddFamily_Click(object sender, RoutedEventArgs e) { AddFamilyWindow addFamilyWindow = new AddFamilyWindow(txtLastName.Text); var res = addFamilyWindow.ShowDialog(); if (res == true) { var familyList = VakacientjesDb.GetFamilies(); int maxId = -1; int selectedIndex = -1; cmbFamily.Items.Clear(); foreach (Family family in familyList) { if (family.Id > maxId) { maxId = family.Id; selectedIndex = familyList.IndexOf(family); } cmbFamily.Items.Add(family.Name); } cmbFamily.SelectedIndex = selectedIndex; } }