private void MoveToTopButton_Click(object sender, RoutedEventArgs e) { var selectedIndex = operationsListBox.SelectedIndex; if (selectedIndex > 0) { StringOperation tmp = _actions[selectedIndex]; _actions[selectedIndex] = _actions[0]; _actions[0] = tmp; operationsListBox.Items.Refresh(); } }
private void MoveToBottomButton_Click(object sender, RoutedEventArgs e) { var selectedIndex = operationsListBox.SelectedIndex; if (selectedIndex < _actions.Count - 1) { StringOperation tmp = _actions[selectedIndex]; _actions[selectedIndex] = _actions[_actions.Count - 1]; _actions[_actions.Count - 1] = tmp; operationsListBox.Items.Refresh(); } }
public PresetImportDialog(BindingList <StringOperation> actions) { InitializeComponent(); _actions = new BindingList <StringOperation>(actions.Select(action => { StringOperation newAction = action.Clone(); newAction.isActive = true; return(newAction); }).ToList()); methodsList.ItemsSource = _actions; }