void XPersonalListBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Delete) { try { var t = ((PersonalProperyShower)XPersonalListBox.SelectedItem).Property; if (t.Type == PropertyType.Contact) { DataBaseInterface.RemoveContact(t); XPersonalListBox.Items.Remove(XPersonalListBox.SelectedItem); } } catch { } } }