internal void IncludedSelected() { if (!string.IsNullOrEmpty(SelectedExcludedVariable)) { var oldSelectedIndex = ExcludedVariables.IndexOf(SelectedExcludedVariable); var whatToMove = SelectedExcludedVariable; IncludedVariables.Add(whatToMove); ExcludedVariables.Remove(whatToMove); SelectedIncludedVariable = whatToMove; if (oldSelectedIndex < ExcludedVariables.Count) { SelectedExcludedVariable = ExcludedVariables[oldSelectedIndex]; } else if (ExcludedVariables.Count > 0) { SelectedExcludedVariable = ExcludedVariables[ExcludedVariables.Count - 1]; } } }