ListBox Item Removal

后端 未结 5 1476
长发绾君心
长发绾君心 2021-01-14 19:15

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

5条回答
  •  梦谈多话
    2021-01-14 20:13

    I Used this logic to preceed. And it worked.

    you may want to try it.

    private void RemoveSelectedButton_Click(object sender, RoutedEventArgs e) {
            if (SelectedSpritesListBox.Items.Count <= 0) return;
    
            ListBoxItem[] temp = new ListBoxItem[SelectedSpritesListBox.SelectedItems.Count];
            SelectedSpritesListBox.SelectedItems.CopyTo(temp, 0);
            for (int i = 0; i < temp.Length; i++) {
                SelectedSpritesListBox.Items.Remove(temp[i]);
            }
        }
    

提交回复
热议问题