public static void InsertItemInItemsControl(ItemsControl itemsControl, OutlinerNote itemToInsert, int insertionIndex) { OutlinerNote parent = itemsControl.DataContext as OutlinerNote; if (parent == null) { parent = (itemToInsert as OutlinerNote).GetRoot(); } OutlinerNote newNote = new OutlinerNote(parent); newNote.Clone(itemToInsert); Window ownerWindow = TreeListView.FindParentWindow(itemsControl); if (ownerWindow == null) { throw new Exception("Window cannot be null"); } DocumentHelpers.CopyNodesRecursively(newNote, itemToInsert); parent.SubNotes.Insert(insertionIndex, newNote); if (itemsControl is TreeListView) { ((TreeListView)itemsControl).MakeActive(newNote, -1, false); } }