/// <summary> /// Fires when user deletes order by pressing 'Delete' button on pop-up window. /// </summary> /// <param name="sender">The button New that the action is for.</param> /// <param name="e">Arguments that the implementor of this event may find useful.</param> private void DeleteOrder(object sender, RoutedEventArgs e) { try { if (OrdersList.SelectedItems.Count != 1) { return; } var selectedItem = (dynamic)OrdersList.SelectedItems[0]; _storage.Remove(selectedItem.Key); OrdersList.SelectedItem = null; EditOrderButton.IsEnabled = false; DeletOrderButton.IsEnabled = false; var orders = _storage.RetrieveAllIds(); if (orders.Count < 1) { OrdersExplorer.IsOpen = false; Opacity = 1; Effect = null; WindowMain.IsEnabled = true; } else { OrdersList.ItemsSource = orders; } } catch (Exception exc) { Util.Error("Order deleting error", exc.Message); } }