Dear All,
I am adding items to UITableView.New Item Adding is fine.It will be inserted at zero index. But i want to check if the new item provided is already in the list.If its already there,first remove it from the list and insert it in zero index.How to do it?
private void AddNewItemAsync(Item item) { Item result = fullItems.Find(x => x.BookId == item.BookId); if(result!=null) { ItemsTableView.BeginUpdates(); fullItems.Remove(result); ItemsTableView.ReloadData(); ItemsTableView.EndUpdates(); } item.NewItemFlag = true; fullItems.Insert(0, item); ItemsTableView.BeginUpdates(); ItemsTableView.InsertRows(new[] { NSIndexPath.Create(0, 0) }, UITableViewRowAnimation.Top); ItemsTableView.EndUpdates(); }
Answers
Modify your code as below