Browse Source

Update StackPanel.cs

pull/2644/head
Wiesław Šoltés 7 years ago
parent
commit
af69f80120
  1. 8
      src/Avalonia.Controls/StackPanel.cs

8
src/Avalonia.Controls/StackPanel.cs

@ -193,7 +193,9 @@ namespace Avalonia.Controls
if (child == null) if (child == null)
{ continue; } { continue; }
if (child.IsVisible) bool isVisible = child.IsVisible;
if (isVisible && !hasVisibleChild)
{ {
hasVisibleChild = true; hasVisibleChild = true;
} }
@ -205,13 +207,13 @@ namespace Avalonia.Controls
// Accumulate child size. // Accumulate child size.
if (fHorizontal) if (fHorizontal)
{ {
stackDesiredSize = stackDesiredSize.WithWidth(stackDesiredSize.Width + (child.IsVisible ? spacing : 0) + childDesiredSize.Width); stackDesiredSize = stackDesiredSize.WithWidth(stackDesiredSize.Width + (isVisible ? spacing : 0) + childDesiredSize.Width);
stackDesiredSize = stackDesiredSize.WithHeight(Math.Max(stackDesiredSize.Height, childDesiredSize.Height)); stackDesiredSize = stackDesiredSize.WithHeight(Math.Max(stackDesiredSize.Height, childDesiredSize.Height));
} }
else else
{ {
stackDesiredSize = stackDesiredSize.WithWidth(Math.Max(stackDesiredSize.Width, childDesiredSize.Width)); stackDesiredSize = stackDesiredSize.WithWidth(Math.Max(stackDesiredSize.Width, childDesiredSize.Width));
stackDesiredSize = stackDesiredSize.WithHeight(stackDesiredSize.Height + (child.IsVisible ? spacing : 0) + childDesiredSize.Height); stackDesiredSize = stackDesiredSize.WithHeight(stackDesiredSize.Height + (isVisible ? spacing : 0) + childDesiredSize.Height);
} }
} }

Loading…
Cancel
Save