private void AccessibilityDemoPage_Loaded(object sender, RoutedEventArgs e)
        {
            var analyzer = new AccessibilityAnalyzer();
            var walker   = new VisualTreeWalker(this, analyzer);

            walker.ScanVisualTree();

            timer = new VisualTreeWalkerTimer(walker);
            timer.Start();
        }
        private static void VerifyElementsVisitedCount(FrameworkElement root, int visitedNoteCount)
        {
            App.Content = root;

            var visitedItems = new List <FrameworkElement>();
            var analyzer     = new CountingElementAnalyzer(visitedItems);
            var walker       = new VisualTreeWalker(root);

            walker.Analyzers.Add(analyzer);

            walker.ScanVisualTree();

            Assert.AreEqual(visitedNoteCount, visitedItems.Count, "Should have visited every element exactly once.");
        }
        public void VerifyVisitingOrderIsBreadthFirstSearch()
        {
            App.Content = new BreadthFirsSearchTestTree();
            var visitedItems = new List <FrameworkElement>();
            var analyzer     = new CountingElementAnalyzer(visitedItems);
            var walker       = new VisualTreeWalker(App.Content);

            walker.Analyzers.Add(analyzer);

            walker.ScanVisualTree();

            Assert.AreEqual(28, visitedItems.Count, "Should have visited every element exactly once.");
            for (int i = 0; i < visitedItems.Count; i++)
            {
                Assert.AreEqual(i.ToString(), visitedItems[i].Tag, "Should have visited items in specific orders");
            }
        }
        public void VerifySkippingBehaviorIsCorrect()
        {
            App.Content = new StackPanel()
            {
                Children =
                {
                    new Button(),
                    new Button(),
                    new Button(),
                    new Button(),
                    new Button()
                }
            };

            var visitedItems = new List <FrameworkElement>();
            var analyzer     = new CountingElementAnalyzer(visitedItems, false);
            var walker       = new VisualTreeWalker(App.Content, analyzer);

            walker.ScanVisualTree();

            Assert.AreEqual(1, visitedItems.Count, "Should have exactly one element.");
        }