private void RemoveGroup_Click(object sender, RoutedEventArgs e) { int SelectedGroupId; SelectedGroupId = GroupsGrid.SelectedIndex; Group SelectedGroup; SelectedGroup = (Group)GroupsGrid.Items[SelectedGroupId]; dbl.RemoveGroup(SelectedGroup); Groups.Remove(SelectedGroup); }