private void Remove_Click(object sender, RoutedEventArgs e) { string text = (string)listBox.SelectedItem; if (text == null) { MessageBox.Show("No user selected"); } else { TextName.Text = ""; imageProfile.Source = null; favourite.Content = "Mark as favourite"; ContactsRepo contRepo = ContactsRepo.Instance(); Contact selectedContact = getContactByUsername(text); contRepo.removeContact(selectedContact.SubjectId, Globals.currentUserId); MessageBox.Show("Change sucessfully saved"); refreshListBox(); ButtonSet(false, false, false); } }