Skip to content

Commit

Permalink
[BUG] [Windows] UniformItemsLayout item positioning not correct #1553 (
Browse files Browse the repository at this point in the history
…#1566)

Co-authored-by: Brandon Minnick <[email protected]>
  • Loading branch information
VladislavAntonyuk and TheCodeTraveler authored Nov 26, 2023
1 parent 19e30af commit 7160815
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,15 @@ public override Size ArrangeChildren(Rect rectangle)
var width = rectangle.Width - uniformItemsLayout.Padding.HorizontalThickness;
var visibleChildren = uniformItemsLayout.Where(x => x.Visibility == Visibility.Visible).ToArray();

if (visibleChildren.Length == 0 || width == 0)
{
return rectangle.Size;
}

var columns = GetColumnsCount(visibleChildren.Length, width);
var rows = GetRowsCount(visibleChildren.Length, columns);

var boundsWidth = columns == 0 ? 0 : width / columns;
var boundsWidth = width / columns;
var boundsHeight = childHeight;
var bounds = new Rect(0, 0, boundsWidth, boundsHeight);
var count = 0;
Expand All @@ -51,7 +56,7 @@ public override Size ArrangeChildren(Rect rectangle)
}
}

return bounds.Size;
return rectangle.Size;
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,14 @@ public void MaxRowsArrangeChildrenUniformItemsLayout()
[Fact]
public void ArrangeChildrenUniformItemsLayout()
{
var expectedSize = new Size(childWidth, childHeight);
uniformChild = new TestView(expectedSize);
var childSize = new Size(childWidth, childHeight);
uniformChild = new TestView(childSize);
uniformItemsLayout.CrossPlatformMeasure(double.PositiveInfinity, double.PositiveInfinity);
var rect = new Rect(0, 0, childWidth * childCount, childHeight * childCount);
uniformItemsLayout.Layout(rect);
var actualSize = uniformItemsLayout.CrossPlatformArrange(rect);

Assert.Equal(expectedSize, actualSize);
Assert.Equal(childSize * childCount, actualSize);
}

class TestView : View
Expand Down

0 comments on commit 7160815

Please sign in to comment.