protected override Size MeasureOverride(Size availableSize)
        {
            Size panelDesiredSize = new Size();

            for (int i = 0; i < Children.Count; i++)
            {
                UIElement child = Children[i];
                Debug.Assert(child != null, "child not expected to be null");
                Debug.Assert(RibbonQuickAccessToolBar.GetIsOverflowItem(child) == true, "child expected to have IsOverflowItem == true");

                Size infinity = new Size(Double.PositiveInfinity, availableSize.Height);
                child.Measure(infinity);
                panelDesiredSize.Width += child.DesiredSize.Width;
                panelDesiredSize.Height = Math.Max(panelDesiredSize.Height, child.DesiredSize.Height);
            }

            return(panelDesiredSize);
        }
        private void ValidateMeasure()
        {
            // validation code

            if (QAT.HasOverflowItems)
            {
                Debug.Assert(GeneratedChildren.Count > InternalChildren.Count);
                int numItemsExpectedInOverflowPanel = GeneratedChildren.Count - InternalChildren.Count;
                Debug.Assert(QAT.OverflowPanel.Children.Count == numItemsExpectedInOverflowPanel);
            }

            // MainPanel
            for (int j = 0; j < InternalChildren.Count; j++)
            {
                Debug.Assert(object.ReferenceEquals(InternalChildren[j], GeneratedChildren[j]));
                UIElement currentChild = InternalChildren[j];
                Debug.Assert(currentChild != null);
                Debug.Assert(RibbonQuickAccessToolBar.GetIsOverflowItem(currentChild) == false);
                Debug.Assert(this.Children.Contains(currentChild) == true);
                Debug.Assert(QAT.OverflowPanel.Children.Contains(currentChild) == false);
                Debug.Assert(currentChild.IsVisible == this.IsVisible);
                Debug.Assert(currentChild.DesiredSize.Width > 0.0);
            }

            // OverflowPanel
            for (int k = InternalChildren.Count; k < GeneratedChildren.Count; k++)
            {
                int overflowPanelIndex = k - InternalChildren.Count;
                Debug.Assert(object.ReferenceEquals(QAT.OverflowPanel.Children[overflowPanelIndex], GeneratedChildren[k]));
                UIElement currentChild = GeneratedChildren[k];
                Debug.Assert(currentChild != null);
                Debug.Assert(RibbonQuickAccessToolBar.GetIsOverflowItem(currentChild) == true);
                Debug.Assert(this.Children.Contains(currentChild) == false);
                Debug.Assert(QAT.OverflowPanel.Children.Contains(currentChild) == true);
            }
        }