protected override Size MeasureOverride(Size availableSize) { if (Children == null || Children.Count < 1) { return new Size (0, 0); } var resultingRect = new Rect (); object accumulatedState = null; try { var count = Children.Count; for (var iter = 0; iter < count; ++iter) { var child = Children[iter]; child.Measure (availableSize); var desiredSize = child.DesiredSize; var args = new LayoutItemEventArgs { LayoutItemState = LayoutItemState.IsMeasuring, UiElement = child, AccumulateState = accumulatedState, State = GetUIElementState (child), AvailableSize = availableSize, DesiredSize = desiredSize, Count = count, Index = iter, Transform = child.RenderTransform, }; OnItemLayout (args); accumulatedState = args.AccumulateState; var childRect = (args.Transform ?? s_identityTransform).TransformBounds (new Rect (0, 0, desiredSize.Width, desiredSize.Height)); resultingRect.Union (childRect); } return availableSize.Merge (resultingRect.ToSize ()); } finally { Common.Dispose (accumulatedState); } }