private void initCommands() { AddCommand = new DelegateCommand(delegate(object arg) { var man = arg as Movement; Movements.Add(man); }); RemoveCommand = new DelegateCommand(delegate(object arg) { var man = arg as Movement; Movements.Remove(man); }); MoveUpCommand = new DelegateCommand(delegate(object arg) { var man = arg as Movement; for (int i = 1; i < Movements.Count; i++) { if (man == Movements[i]) { var ki = Movements[i]; Movements[i] = Movements[i - 1]; Movements[i - 1] = ki; break; } } }); MoveDownCommand = new DelegateCommand(delegate(object arg) { var man = arg as Movement; for (int i = 0; i < Movements.Count - 1; i++) { if (man == Movements[i]) { var ki = Movements[i]; Movements[i] = Movements[i + 1]; Movements[i + 1] = ki; break; } } }); }