public void Visit(TreeNode node)
 {
     this.Context.Add(node);
     foreach (var child in node.Children)
     {
         child.Accept(this);
     }
 }
        private void GenerateInitial()
        {
            var elem0 = new TreeNode("elem 0");
            {
                var elem00 = new TreeNode("elm 00");
                {
                    var elem000 = new TreeLeaf("elm 000");
                    var elem001 = new TreeLeaf("elm 001");

                    elem00.Append(elem000);
                    elem00.Append(elem001);
                }
                var elem01 = new TreeNode("elm 01");
                {
                    var elem010 = new TreeLeaf("elm 010");
                    var elem011 = new TreeLeaf("elm 011");

                    elem01.Append(elem010);
                    elem01.Append(elem011);
                }
                var elem02 = new TreeLeaf("elm 02");

                elem0.Append(elem00);
                elem0.Append(elem01);
                elem0.Append(elem02);
            }
            var elem1 = new TreeNode("elem 1");
            {
                var elem100 = new TreeLeaf("elm 100");
                var elem101 = new TreeLeaf("elm 101");

                elem1.Append(elem100);
                elem1.Append(elem101);
            }

            var source = new ObservableCollection<TreeElementBase>
            {
                elem0,
                elem1
            };

            this.TreeSource = source;
        }
 private void TreeElementSelected(TreeElementSelectedEventArgs args)
 {
     this.selectedElement = args.SelectedElement;
     this.selectedElementParent = args.ParentElement;
     this.selectedIndexToParent = args.IndexToParent;
 }