hey guys i'v been trying to figure it out for 2 days and no luck. i have an observableCollection that stores values and presents them in list box. i want to check item int listbbox(lbBookDetails) and remove it from my collection(myBooks) using delete button.
after i press the delete buttton, i get the element of chosen index,update data for a referenced object inside my chosen Book, and the remove it.
//get chosen book
Book newBook = myBooks.ElementAt(lbBookDetails.SelectedIndex);
//take one book dowfrom authors list
getAuthorByName(newBook.author.fullName()).numOfBooks--;
//remove the book
myBooks.Remove(myBooks.ElementAt(lbBookDetails.SelectedIndex)); //<--- problem
this line sends an event to selectionChange for some reason,and when it searches for index it gets -1 and i have "Argumentoutofrange exception"
why so?