protected override void PrepareContainerForItemOverride(DependencyObject element, object item) { TreeViewItemExtended treeViewItemExtended = (TreeViewItemExtended)element; treeViewItemExtended.ParentTreeView = this.ParentTreeView; treeViewItemExtended.ParentTreeViewItem = this; base.PrepareContainerForItemOverride(element, item); ParentTreeView.InvokeContainerPrepared(treeViewItemExtended, item); }