<NME> TreeViewExtensions.cs
<BEF> ADDFILE
<MSG> Updates to WPFToolBox

<DFF> @@ -0,0 +1,64 @@
+﻿using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows;
+using System.Windows.Controls;
+
+namespace WPFToolboxForPLCs.WPF_Addons
+{
+    public static class TreeViewExtensions
+    {
+        public static TreeViewItem ContainerFromItem(this TreeView treeView, object item)
+        {
+            TreeViewItem containerThatMightContainItem = (TreeViewItem)treeView.ItemContainerGenerator.ContainerFromItem(item);
+            if (containerThatMightContainItem != null)
+                return containerThatMightContainItem;
+            else
+                return ContainerFromItem(treeView.ItemContainerGenerator, treeView.Items, item);
+        }
+
+        private static TreeViewItem ContainerFromItem(ItemContainerGenerator parentItemContainerGenerator, ItemCollection itemCollection, object item)
+        {
+            foreach (object curChildItem in itemCollection)
+            {
+                TreeViewItem parentContainer = (TreeViewItem)parentItemContainerGenerator.ContainerFromItem(curChildItem);
+                if (parentContainer == null)
+                    return null;
+                TreeViewItem containerThatMightContainItem = (TreeViewItem)parentContainer.ItemContainerGenerator.ContainerFromItem(item);
+                if (containerThatMightContainItem != null)
+                    return containerThatMightContainItem;
+                TreeViewItem recursionResult = ContainerFromItem(parentContainer.ItemContainerGenerator, parentContainer.Items, item);
+                if (recursionResult != null)
+                    return recursionResult;
+            }
+            return null;
+        }
+
+        public static object ItemFromContainer(this TreeView treeView, TreeViewItem container)
+        {
+            var itemThatMightBelongToContainer = treeView.ItemContainerGenerator.ItemFromContainer(container);
+            if (itemThatMightBelongToContainer != null && itemThatMightBelongToContainer != DependencyProperty.UnsetValue)
+                return itemThatMightBelongToContainer;
+            else
+                return ItemFromContainer(treeView.ItemContainerGenerator, treeView.Items, container);
+        }
+
+        private static object ItemFromContainer(ItemContainerGenerator parentItemContainerGenerator, ItemCollection itemCollection, TreeViewItem container)
+        {
+            foreach (object curChildItem in itemCollection)
+            {
+                TreeViewItem parentContainer = (TreeViewItem)parentItemContainerGenerator.ContainerFromItem(curChildItem);
+                if (parentContainer == null)
+                    return null;
+                var itemThatMightBelongToContainer = parentContainer.ItemContainerGenerator.ItemFromContainer(container);
+                if (itemThatMightBelongToContainer != null && itemThatMightBelongToContainer != DependencyProperty.UnsetValue)
+                    return itemThatMightBelongToContainer;
+                var recursionResult = ItemFromContainer(parentContainer.ItemContainerGenerator, parentContainer.Items, container);
+                if (recursionResult != null)
+                    return recursionResult;
+            }
+            return null;
+        }
+    }
+}

Updates to WPFToolBox