System.Windows.Controls.ItemContainerGenerator.MoveExistingItems C# (CSharp) Method

MoveExistingItems() public method

public MoveExistingItems ( int index, int offset ) : void
index int
offset int
return void
		void MoveExistingItems (int index, int offset)
		{
			// This is a little horrible. I should really collapse the existing
			// RangeCollection so that every > the current index is decremented by 1.
			// This is easier for now though. I may think of a better way later on.
			RangeCollection newRanges = new RangeCollection ();
			List <int> list = new List<int> ();
			for (int i = 0; i < RealizedElements.Count; i++)
				list.Add (RealizedElements [i]);
			
			if (offset > 0)
				list.Reverse ();

			foreach (int i in list) {
				int oldIndex = i;
				if (oldIndex < index) {
					newRanges.Add (oldIndex);
				} else {
					newRanges.Add (oldIndex + offset);
					var container = ContainerIndexMap [oldIndex];
					ContainerIndexMap.Remove (container, oldIndex);
					ContainerIndexMap.Add (container, oldIndex + offset);
				}
			}

			RealizedElements = newRanges;
		}