Ejemplo n.º 1
0
        void ResetAndAddNew(object sender, RoutedEventArgs e)
        {
            int childCount, levelCount;

            ValidateInput(out childCount, out levelCount);

            dataSource.Clear();
            TreeStructure main = new TreeStructure("Main root", null);

            dataSource.Add(main);
            main.AddSampleChildrenUsingDataBinding(childCount, levelCount);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Default ctor
        /// </summary>
        public HierarchalListBoxTest()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(HierarchalListBoxTest_Loaded);

            dataSource = new ObservableCollection <TreeStructure>();

            //generate some sample data
            for (int i = 0; i < 500; i++)
            {
                TreeStructure child = new TreeStructure(i.ToString(), new TreeStructure[]
                {
                    new TreeStructure("child1 of " + i, new TreeStructure[0]),
                    new TreeStructure("child2 of " + i, new TreeStructure[]
                    {
                        new TreeStructure("child1 of child2 of " + i, new TreeStructure[0]),
                        new TreeStructure("child2 of child2 of " + i, new TreeStructure[0]),
                        new TreeStructure("child3 of child2 of " + i, new TreeStructure[]
                        {
                            new TreeStructure("child1 of child3 of child2 of " + i, new TreeStructure[0]),
                            new TreeStructure("child2 of child3 of child2 of " + i, new TreeStructure[0]),
                            new TreeStructure("child3 of child3 of child2 of " + i, new TreeStructure[0])
                        }),
                    }),
                    new TreeStructure("child3 of " + i, new TreeStructure[0])
                });
                dataSource.Add(child);
            }

            //This string represents the property that contains the child elemnt of the hierarchy
            testList.ChildItemSourcePath = "Children";

            //Please note when using this control set the HierarchalItemsSource not the ItemsSource as follows...
            testList.HierarchalItemsSource = dataSource;

            testTree.ItemsSource = dataSource;
        }
        /// <summary>
        /// Default ctor
        /// </summary>
        public HierarchalListBoxTest()
        {
            InitializeComponent();
            Loaded += new RoutedEventHandler(HierarchalListBoxTest_Loaded);

            dataSource = new ObservableCollection<TreeStructure>();

            //generate some sample data
            for (int i = 0; i < 500; i++)
            {
                TreeStructure child = new TreeStructure(i.ToString(), new TreeStructure[]
                {
                    new TreeStructure("child1 of "+i, new TreeStructure[0]),
                    new TreeStructure("child2 of "+i, new TreeStructure[]
                        {
                            new TreeStructure("child1 of child2 of "+i, new TreeStructure[0]),
                            new TreeStructure("child2 of child2 of "+i, new TreeStructure[0]),
                            new TreeStructure("child3 of child2 of "+i, new TreeStructure[]
                            {
                                new TreeStructure("child1 of child3 of child2 of "+i, new TreeStructure[0]),
                                new TreeStructure("child2 of child3 of child2 of "+i, new TreeStructure[0]),
                                new TreeStructure("child3 of child3 of child2 of "+i, new TreeStructure[0])
                            }),
                        }),
                    new TreeStructure("child3 of "+i, new TreeStructure[0])
                });
                dataSource.Add(child);
            }

            //This string represents the property that contains the child elemnt of the hierarchy
            testList.ChildItemSourcePath = "Children";

            //Please note when using this control set the HierarchalItemsSource not the ItemsSource as follows...
            testList.HierarchalItemsSource = dataSource;

            testTree.ItemsSource = dataSource;

        }
        void ResetAndAddNew(object sender, RoutedEventArgs e)
        {
            int childCount, levelCount;
            ValidateInput(out childCount, out levelCount);

            dataSource.Clear();
            TreeStructure main = new TreeStructure("Main root", null);
            dataSource.Add(main);
            main.AddSampleChildrenUsingDataBinding(childCount, levelCount);
        }