public void RemoveProduct(string Id) { int selIndex = 0; foreach (var item in TryingOnProducts) { if (item.Id == Id) { TryingOnProducts.Remove(item); break; } selIndex++; } //当前删除的也是被选择的 if (currentIndex == selIndex) { if (TryingOnProducts.Count > selIndex) { currentIndex = selIndex; } else { currentIndex = selIndex - 1; } } else { if (selIndex < currentIndex) { currentIndex = currentIndex - 1; } } if (tryingOnProductsRemoved != null) { tryingOnProductsRemoved(); } }