public Window3() { InitializeComponent(); comboBox1.Items.Add(Appointment.AppointmentValue.Agricultural); comboBox1.Items.Add(Appointment.AppointmentValue.Reserved); comboBox1.Items.Add(Appointment.AppointmentValue.UnderBuilding); comboBox2.Items.Add(Description.SoilType.Chalk); comboBox2.Items.Add(Description.SoilType.Clay); comboBox2.Items.Add(Description.SoilType.Loam); comboBox2.Items.Add(Description.SoilType.Peat); comboBox2.Items.Add(Description.SoilType.Sandy); comboBox2.Items.Add(Description.SoilType.Silt); try { Locality l = (Locality)((ListBox)Application.Current.Windows[0].FindName("listBox1")).SelectedItem; ListBox plist = (ListBox)Application.Current.Windows[0].FindName("listBox1"); ListBox pslist = (ListBox)Application.Current.Windows[2].FindName("listBox1"); if (pslist != null && pslist.Items.Count != 0) { Property p = (Property)pslist.SelectedItem; if (p != null) { pslist.Items.Remove(p); l.RemoveProperty(p); plist.Items.Remove(p); } } } catch (Exception ex) { } }