I’m trying to simply remove an item from a private ObservableCollection<ProjectInformation> _sourceCollection = new ObservableCollection<ProjectInformation>();
, which is binded to a ListBox:
_sourceCollection.RemoveAt(1);
Nothing to do (with Count = 3, and index 1):
Execute this instruction give to me a ThrowHelper.ThrowArgumentOutOfRange_IndexException(); exception: System.ArgumentOutOfRangeException: ‘Index was out of range. Must be non-negative and less than the size of the collection. Arg_ParamName_Name’
Tried also ListBox.Items.RemoveAt(1), or different strategy. Can’t do the task. What’s wrong? ListBox.SelectedIndex gives to me 1. Looks these but nothing helps:
- i can’t remove the index in list box
- How to add a new item in listbox which binding from code behind to xaml page
What am I missing?