Пример #1
0
        public void AddItem()
        {
            DataItem parent = (DataItem)TreeView.SelectedItem;

            if (parent == null)
            {
                parent = TreeView.Items.OfType <DataItem>().First();
            }

            for (int i = 0; i < 1; i++)
            {
                DataItem item = new DataItem("New Item " + i);
                item.Parent = parent;
                parent.Children.Add(item);
            }

            VirtualizingItemContainer itemContainer = TreeView.GetItemContainer(parent);

            if (itemContainer != null)
            {
                //Update arrow visiblity
                TreeView.DataBindItem(parent, itemContainer);
                TreeView.Expand(parent);
            }
        }