Exemplo n.º 1
0
 private void UnregisterItem(TreeViewItem item)
 {
     item.Expanded  -= ExpandedChanged;
     item.Collapsed -= ExpandedChanged;
     foreach (var container in GetItems(item))
     {
         UnregisterItem(container);
     }
 }
Exemplo n.º 2
0
        private static IEnumerable <TreeViewItem> GetItems(TreeViewItem parent)
        {
            var item = TreeViewElementFinder.GetFirstVirtualizedItem(parent);

            if (item == null)
            {
                yield break;
            }

            while (item != null)
            {
                yield return(item);

                item = (TreeViewItem)TreeViewElementFinder.FindNextSibling(item);
            }
        }
Exemplo n.º 3
0
        private static bool IsParentOfItem(TreeViewItem item, IEnumerable <TreeViewItem> parentCandidates)
        {
            foreach (var parent in parentCandidates)
            {
                var current = item.ParentTreeViewItem;
                while (current != null)
                {
                    if (ReferenceEquals(current, parent))
                    {
                        return(true);
                    }

                    current = current.ParentTreeViewItem;
                }
            }
            return(false);
        }
Exemplo n.º 4
0
        private TreeViewItem GetTreeViewItem(string propertyPath)
        {
            IEnumerable <TreeViewItem> currentPropertyCollection = GetItems(AssociatedObject);

            string[]     members = propertyPath.Split('.');
            TreeViewItem item    = null;

            foreach (var member in members.Skip(0))
            {
                item = currentPropertyCollection.FirstOrDefault(x => { var vm = x.DataContext as IChildViewModel; return(vm != null && GetName(vm) == member); });
                if (item == null)
                {
                    return(null);
                }

                currentPropertyCollection = GetItems(item);
            }
            return(item);
        }