private void Btn_add_Click(object sender, RoutedEventArgs e) { var item = new FoodItem() { visibility = "Collapsed", visibilityAdd = "Visible", isAvailable = true, foodType = "Non-Veg", quantity = 1, imagePath = "pack://application:,,,/Food Images/upload_image.jpg", category = "Main Menu" }; foodItems.Add(item); Lbx_fooditems.SelectedItem = item; Lbx_fooditems.ScrollIntoView(item); }
private void Btn_add_Click(object sender, RoutedEventArgs e) { Spl_orders.Visibility = Visibility.Visible; Grid_main.Margin = new Thickness(0, 0, 355, 0); var btn_add = sender as Button; FoodItem selectedItem = (from food in foodItems where food.name == btn_add.Tag select food).FirstOrDefault(); selectedItem.visibility = "Visible"; selectedItem.visibilityAdd = "Collapsed"; OrderItem orderItem; orderItem = new OrderItem { item = new FoodItem() }; orderItem.item.name = selectedItem.name; orderItem.itemQuantity += 1; orderItem.itemTotal = (selectedItem.price * orderItem.itemQuantity); orderItems.Add(orderItem); Tbx_total.Text = getTotalPrice().ToString(); Lbx_Orderitems.ItemsSource = orderItems; Lbx_Orderitems.ScrollIntoView(orderItems.LastOrDefault()); Lbx_fooditems.ScrollIntoView(selectedItem); Lbx_fooditems.SelectedItem = selectedItem; }