Ejemplo n.º 1
0
        private static void IterateVisualChildren(DependencyObject parent, HwndContentControlAutomationPeer.IteratorCallback callback)
        {
            if (parent == null)
            {
                return;
            }
            int childrenCount = VisualTreeHelper.GetChildrenCount(parent);

            for (int childIndex = 0; childIndex < childrenCount; ++childIndex)
            {
                DependencyObject child       = VisualTreeHelper.GetChild(parent, childIndex);
                UIElement        element     = child as UIElement;
                UIElement3D      uiElement3D = child as UIElement3D;
                AutomationPeer   peerForElement1;
                if (element != null && (peerForElement1 = UIElementAutomationPeer.CreatePeerForElement(element)) != null)
                {
                    callback(peerForElement1);
                }
                else
                {
                    AutomationPeer peerForElement2;
                    if (uiElement3D != null && (peerForElement2 = UIElement3DAutomationPeer.CreatePeerForElement((UIElement3D)child)) != null)
                    {
                        callback(peerForElement2);
                    }
                    else
                    {
                        HwndContentControlAutomationPeer.IterateVisualChildren(child, callback);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        protected override List <AutomationPeer> GetChildrenCore()
        {
            List <AutomationPeer> children = (List <AutomationPeer>)null;

            HwndContentControlAutomationPeer.IterateVisualChildren((DependencyObject)this.VisualSubtree, (HwndContentControlAutomationPeer.IteratorCallback)(peer =>
            {
                if (children == null)
                {
                    children = new List <AutomationPeer>();
                }
                children.Add(peer);
            }));
            return(children);
        }