From 7591ff1b4bece6b27346dd147f673603aefbf997 Mon Sep 17 00:00:00 2001 From: David Britch Date: Tue, 23 Jan 2024 12:18:30 +0000 Subject: [PATCH] Minor edits. --- .../CustomLayoutDemos/Layouts/HorizontalWrapLayout.cs | 3 +-- .../Layouts/HorizontalWrapLayoutManager.cs | 9 ++++----- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/8.0/UserInterface/CustomLayoutDemos/CustomLayoutDemos/Layouts/HorizontalWrapLayout.cs b/8.0/UserInterface/CustomLayoutDemos/CustomLayoutDemos/Layouts/HorizontalWrapLayout.cs index ca0227d5f..f60958f10 100644 --- a/8.0/UserInterface/CustomLayoutDemos/CustomLayoutDemos/Layouts/HorizontalWrapLayout.cs +++ b/8.0/UserInterface/CustomLayoutDemos/CustomLayoutDemos/Layouts/HorizontalWrapLayout.cs @@ -2,7 +2,7 @@ namespace CustomLayoutDemos.Layouts { - public class HorizontalWrapLayout : StackLayout + public class HorizontalWrapLayout : HorizontalStackLayout { protected override ILayoutManager CreateLayoutManager() { @@ -10,4 +10,3 @@ protected override ILayoutManager CreateLayoutManager() } } } - diff --git a/8.0/UserInterface/CustomLayoutDemos/CustomLayoutDemos/Layouts/HorizontalWrapLayoutManager.cs b/8.0/UserInterface/CustomLayoutDemos/CustomLayoutDemos/Layouts/HorizontalWrapLayoutManager.cs index 7c80182d9..ee0c924e6 100644 --- a/8.0/UserInterface/CustomLayoutDemos/CustomLayoutDemos/Layouts/HorizontalWrapLayoutManager.cs +++ b/8.0/UserInterface/CustomLayoutDemos/CustomLayoutDemos/Layouts/HorizontalWrapLayoutManager.cs @@ -1,9 +1,9 @@ using Microsoft.Maui.Layouts; -using StackLayoutManager = Microsoft.Maui.Layouts.StackLayoutManager; +using HorizontalStackLayoutManager = Microsoft.Maui.Layouts.HorizontalStackLayoutManager; namespace CustomLayoutDemos.Layouts { - public class HorizontalWrapLayoutManager : StackLayoutManager + public class HorizontalWrapLayoutManager : HorizontalStackLayoutManager { HorizontalWrapLayout _layout; @@ -26,7 +26,6 @@ public override Size Measure(double widthConstraint, double heightConstraint) for (int n = 0; n < _layout.Count; n++) { var child = _layout[n]; - if (child.Visibility == Visibility.Collapsed) { continue; @@ -65,13 +64,13 @@ public override Size Measure(double widthConstraint, double heightConstraint) totalWidth += padding.HorizontalThickness; totalHeight += padding.VerticalThickness; + // Ensure that the total size of the layout fits within its constraints var finalWidth = ResolveConstraints(widthConstraint, Stack.Width, totalWidth, Stack.MinimumWidth, Stack.MaximumWidth); var finalHeight = ResolveConstraints(heightConstraint, Stack.Height, totalHeight, Stack.MinimumHeight, Stack.MaximumHeight); return new Size(finalWidth, finalHeight); } - public override Size ArrangeChildren(Rect bounds) { var padding = Stack.Padding; @@ -87,7 +86,6 @@ public override Size ArrangeChildren(Rect bounds) for (int n = 0; n < _layout.Count; n++) { var child = _layout[n]; - if (child.Visibility == Visibility.Collapsed) { continue; @@ -113,6 +111,7 @@ public override Size ArrangeChildren(Rect bounds) var actual = new Size(maxStackWidth, currentRowTop + currentRowHeight); + // Adjust the size if the layout is set to fill its container return actual.AdjustForFill(bounds, Stack); } }