diff --git a/src/Avalonia.Controls/DockPanel.cs b/src/Avalonia.Controls/DockPanel.cs index 5c9c2208b72..de6fc11eba1 100644 --- a/src/Avalonia.Controls/DockPanel.cs +++ b/src/Avalonia.Controls/DockPanel.cs @@ -157,17 +157,23 @@ protected override Size MeasureOverride(Size availableSize) { case Dock.Left: case Dock.Right: - horizontalSpacing = true; parentHeight = Math.Max(parentHeight, accumulatedHeight + childDesiredSize.Height); - accumulatedWidth += HorizontalSpacing; + if (!child.IsVisible) + { + accumulatedWidth += HorizontalSpacing; + horizontalSpacing = true; + } accumulatedWidth += childDesiredSize.Width; break; case Dock.Top: case Dock.Bottom: - verticalSpacing = true; parentWidth = Math.Max(parentWidth, accumulatedWidth + childDesiredSize.Width); - accumulatedHeight += VerticalSpacing; + if (!child.IsVisible) + { + accumulatedHeight += VerticalSpacing; + verticalSpacing = true; + } accumulatedHeight += childDesiredSize.Height; break; }