/// <summary> /// Method that removes an item from the order when a user clicks the "X" button on that item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnRemoveButtonClicked(object sender, RoutedEventArgs e) { if (sender is Button) { Button b = (Button)sender; IOrderItem itemToBeRemoved = (IOrderItem)b.DataContext; Order ord = (Order)DataContext; ord.Remove(itemToBeRemoved); } }
/// <summary> /// Removes item /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void OnRemoveItem(object sender, RoutedEventArgs e) { if (sender is Button) { Button b = (Button)sender; IOrderItem i = (IOrderItem)b.DataContext; Order o = (Order)DataContext; o.Remove(i); } }
private void DeleteBtn_Click(object sender, RoutedEventArgs e) { Order items = DataContext as Order; var item = (e.OriginalSource as FrameworkElement).DataContext; items.Remove(item as IOrderItem); var screen = new MenuItemSelectionControl(); var orderControl = this.FindAncestor <OrderControl>(); orderControl?.SwapScreen(screen); }
/// <summary> /// Removes the item when the X button is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnRemoveItem(object sender, RoutedEventArgs e) { if (DataContext is Order Order) { if (sender is Button button) { IOrderItem item = button.DataContext as IOrderItem; Order.Remove(item); } } }
/// <summary> /// clears order /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ClearOrderItem(object sender, RoutedEventArgs e) { if (DataContext is Order order) { int index = itemsListView.SelectedIndex; order.Remove(order[index]); //how to find index of one I want to remove? //need a reference to the item that needs to be deleted } }
void clickRemoveItem(object sender, RoutedEventArgs e) { try { ListViewItem selectedItem = (ListViewItem)listview.SelectedItem; if (selectedItem != null) { IOrderItem i = (IOrderItem)selectedItem.Tag; Orders.Remove(i); listviewload(); } } catch (Exception ex) { throw new NotImplementedException(ex.ToString()); } }
private void DeleteItem(object sender, RoutedEventArgs e) { if (sender is Button b) { if (b.DataContext is IOrderItem item) { try { Order currentOrder = (Order)this.DataContext; currentOrder.Remove(item); } catch { throw new System.Exception(); } } } ReplaceScreen(); }
private void TryAddEntree(Entree e) { if (entree == null) { Order order = (Order)DataContext; entree = e; if (!isForCombo) { order.Add(entree); } } else { Order order = (Order)DataContext; if (!isForCombo) { order.Remove(entree); } entree = e; if (!isForCombo) { order.Add(entree); } } CustomizeEntree ce = new CustomizeEntree(entree, isForCombo); ce.DataContext = this.DataContext; NavigationService.Navigate(ce); /* * MainWindow mw = (MainWindow)Application.Current.MainWindow; * mw.OrderList.OrderItems.SelectedItem = entree; * * NavigationService.Navigate(new MenuCategorySelection()); */ }
private void RemoveItem(object sender, RoutedEventArgs e) { order.Remove((IOrderItem)ordersListBox.SelectedItem); }
/// <summary> /// removes item from Order named price /// </summary> /// <param name="item">item</param> public void Remove(IOrderItem item) { price.Remove(price[itemsListView.SelectedIndex]); }
/// <summary> /// Listener for removing an item from order /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void OnRemoveClick(object sender, RoutedEventArgs e) { IOrderItem item = listView.SelectedItem as IOrderItem; order.Remove(item); }