Ejemplo n.º 1
0
        public void UpdateLayout()
        {
            while (measureQueue.Count > 0 || arrangeQueue.Count > 0)
            {
                while (measureQueue.Count > 0)
                {
                    UIElement element             = GetTopElement(measureQueue);
                    Size      previousDesiredSize = element.DesiredSize;

                    element.Measure(element.PreviousAvailableSize);

                    if (previousDesiredSize != element.DesiredSize)
                    {
                        element.InvalidateArrange();
                        element.InvalidateParentMeasure();
                    }
                }

                while (arrangeQueue.Count > 0)
                {
                    UIElement element = GetTopElement(arrangeQueue);
                    element.Arrange(element.PreviousFinalRect);
                }

                while (updatedElements.Count > 0 && measureQueue.Count == 0 && arrangeQueue.Count == 0) // LayoutUpdated can invalidate other elements
                {
                    UIElement element = updatedElements.First();
                    updatedElements.Remove(element);

                    element.RaiseLayoutUpdated();
                }
            }
        }