Skip to content

Commit

Permalink
Fix WrapPanel when ItemWidth < Available Size
Browse files Browse the repository at this point in the history
  • Loading branch information
SuperJMN committed Nov 28, 2024
1 parent e8ce578 commit 13e1445
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/Avalonia.Controls/WrapPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ protected override Size MeasureOverride(Size constraint)
var childConstraint = new Size(
itemWidthSet ? itemWidth : constraint.Width,
itemHeightSet ? itemHeight : constraint.Height);

for (int i = 0, count = children.Count; i < count; i++)
{
var child = children[i];
Expand Down Expand Up @@ -213,14 +213,18 @@ protected override Size ArrangeOverride(Size finalSize)
if (MathUtilities.GreaterThan(sz.U, uvFinalSize.U)) // The element is wider then the constraint - give it a separate line
{
// Switch to next line which only contain one element
ArrangeLine(accumulatedV, sz.V, i, ++i, useItemU, itemU);
ArrangeLine(accumulatedV, sz.V, i, i + 1, useItemU, itemU);

accumulatedV += sz.V;
curLineSize = new UVSize(orientation);
firstInLine = i + 1;
}
else
{
firstInLine = i;
}
firstInLine = i;
}
else // Continue to accumulate a line
else // Continue to accumulate in the current line
{
curLineSize.U += sz.U;
curLineSize.V = Max(sz.V, curLineSize.V);
Expand Down

0 comments on commit 13e1445

Please sign in to comment.