From 705ebc26752a1b9e956cda8ac5dd908eb1883e59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wies=C5=82aw=20=C5=A0olt=C3=A9s?= Date: Mon, 10 Jun 2019 22:30:37 +0200 Subject: [PATCH] Update StackPanel.cs --- src/Avalonia.Controls/StackPanel.cs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/Avalonia.Controls/StackPanel.cs b/src/Avalonia.Controls/StackPanel.cs index c2f36b94d7..fd75353364 100644 --- a/src/Avalonia.Controls/StackPanel.cs +++ b/src/Avalonia.Controls/StackPanel.cs @@ -205,13 +205,13 @@ namespace Avalonia.Controls // Accumulate child size. if (fHorizontal) { - stackDesiredSize = stackDesiredSize.WithWidth(stackDesiredSize.Width + childDesiredSize.Width + (child.IsVisible ? spacing : 0)); + stackDesiredSize = stackDesiredSize.WithWidth(stackDesiredSize.Width + (child.IsVisible ? spacing : 0) + childDesiredSize.Width); stackDesiredSize = stackDesiredSize.WithHeight(Math.Max(stackDesiredSize.Height, childDesiredSize.Height)); } else { stackDesiredSize = stackDesiredSize.WithWidth(Math.Max(stackDesiredSize.Width, childDesiredSize.Width)); - stackDesiredSize = stackDesiredSize.WithHeight(stackDesiredSize.Height + childDesiredSize.Height + (child.IsVisible ? spacing : 0)); + stackDesiredSize = stackDesiredSize.WithHeight(stackDesiredSize.Height + (child.IsVisible ? spacing : 0) + childDesiredSize.Height); } } @@ -224,7 +224,9 @@ namespace Avalonia.Controls stackDesiredSize = stackDesiredSize.WithHeight(stackDesiredSize.Height - (hasVisibleChild ? spacing : 0)); } - return stackDesiredSize.Constrain(availableSize); // TODO: In WPF `.Constrain(availableSize)` is not used. + return stackDesiredSize; + // TODO: In WPF `.Constrain(availableSize)` is not used. + //return stackDesiredSize.Constrain(availableSize); } /// @@ -251,15 +253,15 @@ namespace Avalonia.Controls if (fHorizontal) { - rcChild = rcChild.WithX(rcChild.X + previousChildSize); - previousChildSize = child.DesiredSize.Width + (child.IsVisible ? spacing : 0); + rcChild = rcChild.WithX(rcChild.X + previousChildSize + spacing); + previousChildSize = child.DesiredSize.Width;//+ (child.IsVisible ? spacing : 0); rcChild = rcChild.WithWidth(previousChildSize); rcChild = rcChild.WithHeight(Math.Max(finalSize.Height, child.DesiredSize.Height)); } else { - rcChild = rcChild.WithY(rcChild.Y + previousChildSize); - previousChildSize = child.DesiredSize.Height + (child.IsVisible ? spacing : 0); + rcChild = rcChild.WithY(rcChild.Y + previousChildSize + spacing); + previousChildSize = child.DesiredSize.Height;//+ (child.IsVisible ? spacing : 0); rcChild = rcChild.WithHeight(previousChildSize); rcChild = rcChild.WithWidth(Math.Max(finalSize.Width, child.DesiredSize.Width)); }