// <summary>
        // Gets a list of AutomationPeers that contains the following:
        //     Type text box
        //     Name text box
        //     List of CategoryContainerAutomationPeers
        // </summary>
        // <returns></returns>
        protected override List <AutomationPeer> GetChildrenCore()
        {
            // If children list is not null and contains AutomationPeer that implements IAutomationFocusChangedEventSource
            // Then, unhook the automation focus events before clearing the list
            // Else, create a new one.
            if (_children != null)
            {
                foreach (AutomationPeer peer in _children)
                {
                    IAutomationFocusChangedEventSource unhookEventPeer = peer as IAutomationFocusChangedEventSource;
                    if (unhookEventPeer != null)
                    {
                        unhookEventPeer.UnloadEventHook();
                    }
                }
                _children.Clear();
            }
            else
            {
                _children = new List <AutomationPeer>();
            }
            _children.Add(new TextBlockAutomationPeer(_inspector.SelectionTypeLabel));
            _children.Add(new UIElementAutomationPeer(_inspector.PropertyToolBar));
            _children.Add(new InfoTextBlockAutomationPeer(_inspector.UninitializedLabel));
            _children.Add(new InfoTextBlockAutomationPeer(_inspector.NoSearchResultsLabel));
            _children.Add(new CategoryListAutomationPeer(_inspector.CategoryList));

            return(_children);
        }
Beispiel #2
0
 // IAutomationFocusChangedEventSource Members
 public void UnloadEventHook()
 {
     if (_children != null)
     {
         foreach (AutomationPeer peer in _children)
         {
             IAutomationFocusChangedEventSource unhookEventPeer = peer as IAutomationFocusChangedEventSource;
             if (unhookEventPeer != null)
             {
                 unhookEventPeer.UnloadEventHook();
             }
         }
     }
 }
        protected override List <AutomationPeer> GetChildrenCore()
        {
            if (_children != null)
            {
                foreach (AutomationPeer peer in _children)
                {
                    IAutomationFocusChangedEventSource unhookEventPeer = peer as IAutomationFocusChangedEventSource;
                    if (unhookEventPeer != null)
                    {
                        unhookEventPeer.UnloadEventHook();
                    }
                }
                _children.Clear();
            }

            // See if we have access to the QuickTypes combo box (it may or may not be available)
            AutomatedChoiceEditor choiceEditor = VisualTreeUtils.GetNamedChild <AutomatedChoiceEditor>(_editor, "PART_ValueEditor");

            // If we do, present it as one of our children
            if (choiceEditor != null)
            {
                _children.Add(new HiddenUIElementAutomationPeer(choiceEditor));
            }

            // Add any sub-properties
            ItemsControl properties = VisualTreeUtils.GetNamedChild <ItemsControl>(_editor, "PART_SubPropertyList");

            if (properties != null)
            {
                int childCount = properties.Items.Count;

                for (int i = 0; i < childCount; i++)
                {
                    PropertyContainer propertyContainer = properties.ItemContainerGenerator.ContainerFromIndex(i) as PropertyContainer;

                    if (propertyContainer != null)
                    {
                        PropertyContainerAutomationPeer peer = new PropertyContainerAutomationPeer(propertyContainer);
                        _children.Add(peer);
                    }
                }
            }

            return(_children);
        }