public int MoveMapListItemDown(MapListItemViewModel currentItem) { var items = this.MapList.Items; var currentIndex = items.IndexOf(currentItem.Item); if (currentIndex == items.Count - 1 ) { return currentIndex; } var nextIndex = currentIndex + 1; items.RemoveAt(currentIndex); items.Insert(nextIndex, currentItem.Item); this.InitializeMapListItems(); InvokePropertyChanged(null); return nextIndex; }
public int MoveMapListItemUp(MapListItemViewModel currentItem) { var items = this.MapList.Items; var currentIndex = items.IndexOf(currentItem.Item); if (currentIndex == 0) { // it's the first item, no chance to move it up return 0; } var nextIndex = currentIndex - 1; items.Insert(nextIndex, currentItem.Item); items.RemoveAt(currentIndex + 1); this.InitializeMapListItems(); InvokePropertyChanged(null); return nextIndex; }