ComponentFactory.Quicksilver.Layout.MetaElementCollection.Insert C# (CSharp) Method

Insert() public method

Inserts an element into a collection at the specified index position.
public Insert ( int index, UIElement element ) : void
index int The index position where you want to insert the element.
element UIElement The element to insert into the collection.
return void
        public override void Insert(int index, UIElement element)
        {
            if (_isItemsHost)
                base.Insert(index, element);
            else
            {
                ValidateElement(element);
                VerifyWriteAccess();

                // Add to the external list
                _externalChildren.Insert(index, element);

                // Add to internal logical tree
                SetLogicalParent(element);

                // Add to the internal visual tree (in same relative position in the visual collection)
                if (_internalChildren.Count == 0)
                    _internalChildren.Add(element);
                else if (index == 0)
                    _internalChildren.Insert(0, element);
                else
                    _internalChildren.Insert(_internalChildren.IndexOf(_externalChildren[index - 1]) + 1, element);

                // Instruct the visual parent it must measure with the new child element
                _visualParent.InvalidateMeasure();

                // Added event is always generated after the base call
                OnUIElementsAdded(new UIElementsEventArgs(element));
            }
        }