private void DeleteItems(object sender, RoutedEventArgs e) { if (MasterListView.SelectedIndex != -1) { List <Smartphone> selectedItems = new List <Smartphone>(); var mobileService = new ServicioDatos(); foreach (Smartphone sm in MasterListView.SelectedItems) { selectedItems.Add(sm); } foreach (Smartphone sm in selectedItems) { Smartphones.Remove(sm); mobileService.DeleteSmartphone(sm); } if (MasterListView.Items.Count > 0) { MasterListView.SelectedIndex = 0; smartphoneSeleccionado = MasterListView.SelectedItem as Smartphone; } else { DetailContentPresenter.Visibility = Visibility.Collapsed; } } }
private void DeleteItem(object sender, RoutedEventArgs e) { if (smartphoneSeleccionado != null) { var mobileService = new ServicioDatos(); Smartphones.Remove(smartphoneSeleccionado); mobileService.DeleteSmartphone(smartphoneSeleccionado); if (MasterListView.Items.Count > 0) { MasterListView.SelectedIndex = 0; smartphoneSeleccionado = MasterListView.SelectedItem as Smartphone; } else { DetailContentPresenter.Visibility = Visibility.Collapsed; smartphoneSeleccionado = null; } } }