From e56f1ab83aa57b3f82992b83d6eca062677ce802 Mon Sep 17 00:00:00 2001 From: walterlv Date: Sun, 22 Apr 2018 17:20:20 +0800 Subject: [PATCH] If the MinHeight/MinWidth is set and it affects the Grid layout, a new calculation will be triggered. (Not only the MaxHeight/MaxWidth) --- src/Avalonia.Controls/Grid.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/Grid.cs b/src/Avalonia.Controls/Grid.cs index 63e74d62b1..02c961c179 100644 --- a/src/Avalonia.Controls/Grid.cs +++ b/src/Avalonia.Controls/Grid.cs @@ -235,6 +235,9 @@ namespace Avalonia.Controls } else if (height.GridUnitType == GridUnitType.Star) { + _rowMatrix[i, i].OfferedSize = Clamp(0, _rowMatrix[i, i].Min, _rowMatrix[i, i].Max); + _rowMatrix[i, i].DesiredSize = _rowMatrix[i, i].OfferedSize; + _rowMatrix[i, i].Stars = height.Value; totalStarsY += height.Value; } @@ -270,6 +273,9 @@ namespace Avalonia.Controls } else if (width.GridUnitType == GridUnitType.Star) { + _colMatrix[i, i].OfferedSize = Clamp(0, _colMatrix[i, i].Min, _colMatrix[i, i].Max); + _colMatrix[i, i].DesiredSize = _colMatrix[i, i].OfferedSize; + _colMatrix[i, i].Stars = width.Value; totalStarsX += width.Value; } @@ -725,9 +731,10 @@ namespace Avalonia.Controls double newsize = segmentSize; newsize += contribution * (type == GridUnitType.Star ? matrix[i, i].Stars : 1); + double newSizeIgnoringMinMax = newsize; newsize = Math.Min(newsize, matrix[i, i].Max); newsize = Math.Max(newsize, matrix[i, i].Min); - assigned |= newsize > segmentSize; + assigned |= !Equals(newsize, newSizeIgnoringMinMax); size -= newsize - segmentSize; if (desiredSize)