I have a WPF window that manages sets of configurations and it allows users to edit a configuration set (edit button) and to remove a configuration set (remove button). The
for (int i = lstAttachments.SelectedItems.Count - 1; i >= 0; i--) { lstAttachments.Items.Remove(lstAttachments.SelectedItems[i]); }
Simplest way to remove items from a list you iterate through is going backwards because it does not affect the index of items you are moving next to.