private void ButtonCharacterMoveDown_Click(object sender, RoutedEventArgs e) { var csIndex = _csManager.IndexOf(ListBoxCharacterData.ItemsSource as CharacterSet); var indices = ListBoxCharacterData.SelectedIndices(ListSortDirection.Descending); foreach (var index in indices) { _csManager[csIndex].Move(index, index + 1); } ValidateMoveButtonEnableStatus(ListSortDirection.Descending); }
private void ValidateMoveButtonEnableStatus(ListSortDirection direction) { if (ListBoxCharacterData.SelectedItems.Count > 0) { var indices = ListBoxCharacterData.SelectedIndices(direction).ToList(); ButtonCharacterMoveUp.IsEnabled = indices.Min() > 0; ButtonCharacterMoveDown.IsEnabled = indices.Max() < ListBoxCharacterData.Items.Count - 1; } else { ButtonCharacterMoveUp.IsEnabled = false; ButtonCharacterMoveDown.IsEnabled = false; } }