diff --git a/dev/Repeater/APITests/FlowLayoutTests.cs b/dev/Repeater/APITests/FlowLayoutTests.cs index 7ed6a53a01..aa60b01c86 100644 --- a/dev/Repeater/APITests/FlowLayoutTests.cs +++ b/dev/Repeater/APITests/FlowLayoutTests.cs @@ -136,16 +136,16 @@ public void ValidateGridLayout() canvas.Children.Add(panel); Content = canvas; Content.UpdateLayout(); - int minItemSpacing = 0; - int lineSpacing = 0; - ValidateGridLayoutChildrenLayoutBounds(om, (i) => panel.Children[i], itemMinorSize, itemMajorSize, minItemSpacing, lineSpacing, panel.Children.Count, panel.DesiredSize); - - minItemSpacing = 10; - lineSpacing = 10; - ((UniformGridLayout)panel.Layout).MinRowSpacing = minItemSpacing; - ((UniformGridLayout)panel.Layout).MinColumnSpacing = lineSpacing; + int minRowSpacing = 0; + int minColumnSpacing = 0; + ValidateGridLayoutChildrenLayoutBounds(om, (i) => panel.Children[i], itemMinorSize, itemMajorSize, minRowSpacing, minColumnSpacing, panel.Children.Count, panel.DesiredSize); + + minRowSpacing = 5; + minColumnSpacing = 10; + ((UniformGridLayout)panel.Layout).MinRowSpacing = minRowSpacing; + ((UniformGridLayout)panel.Layout).MinColumnSpacing = minColumnSpacing; Content.UpdateLayout(); - ValidateGridLayoutChildrenLayoutBounds(om, (i) => panel.Children[i], itemMinorSize, itemMajorSize, minItemSpacing, lineSpacing, panel.Children.Count, panel.DesiredSize); + ValidateGridLayoutChildrenLayoutBounds(om, (i) => panel.Children[i], itemMinorSize, itemMajorSize, minRowSpacing, minColumnSpacing, panel.Children.Count, panel.DesiredSize); } } }); @@ -1245,13 +1245,16 @@ private void ValidateGridLayoutChildrenLayoutBounds( Func elementAtIndexFunc, double itemMinorSize, double itemMajorSize, - double minItemSpacing, - double lineSpacing, + double minRowSpacing, + double minColumnSpacing, int childCount, Size desiredSize) { var expectedRect = om.MinorMajorRect(0, 0, itemMinorSize, itemMajorSize); double extentMajor = 0; + var minItemSpacing = om.ScrollOrientation == ScrollOrientation.Vertical ? minColumnSpacing : minRowSpacing; + var lineSpacing = om.ScrollOrientation == ScrollOrientation.Vertical ? minRowSpacing : minColumnSpacing; + for (int i = 0; i < childCount; i++) { var child = (FrameworkElement)elementAtIndexFunc(i); @@ -1384,8 +1387,9 @@ private void ValidateLayoutEstimations(ScrollOrientation scrollOrientation, Layo break; case LayoutChoice.Grid: - - layout = new UniformGridLayout() { MinItemWidth = itemSize, MinItemHeight = itemSize, MinColumnSpacing = lineSpacing }; + var minRowSpacing = om.ScrollOrientation == ScrollOrientation.Vertical ? lineSpacing : 0; + var minColumnSpacing = om.ScrollOrientation == ScrollOrientation.Horizontal ? lineSpacing : 0; + layout = new UniformGridLayout() { MinItemWidth = itemSize, MinItemHeight = itemSize, MinRowSpacing = minRowSpacing, MinColumnSpacing = minColumnSpacing }; break; case LayoutChoice.Flow: diff --git a/dev/Repeater/UniformGridLayout.h b/dev/Repeater/UniformGridLayout.h index 857a98da3f..aec58e5f3b 100644 --- a/dev/Repeater/UniformGridLayout.h +++ b/dev/Repeater/UniformGridLayout.h @@ -95,12 +95,13 @@ class UniformGridLayout : double LineSpacing() { - return ScrollOrientation() == ScrollOrientation::Vertical ? m_minColumnSpacing : m_minRowSpacing; + return Orientation() == winrt::Orientation::Horizontal ? m_minRowSpacing: m_minColumnSpacing; + } double MinItemSpacing() { - return ScrollOrientation() == ScrollOrientation::Vertical ? m_minRowSpacing : m_minColumnSpacing; + return Orientation() == winrt::Orientation::Horizontal ? m_minColumnSpacing: m_minRowSpacing; } // Fields diff --git a/dev/Repeater/UniformGridLayoutState.cpp b/dev/Repeater/UniformGridLayoutState.cpp index be27344ab7..b75cb60edb 100644 --- a/dev/Repeater/UniformGridLayoutState.cpp +++ b/dev/Repeater/UniformGridLayoutState.cpp @@ -82,7 +82,7 @@ void UniformGridLayoutState::SetSize( m_effectiveItemHeight = (std::isnan(LayoutItemHeight) ? UIElement.DesiredSize().Height : LayoutItemHeight); auto availableSizeMinor = orientation == winrt::Orientation::Horizontal ? availableSize.Width : availableSize.Height; - auto minorItemSpacing = orientation == winrt::Orientation::Horizontal ? minRowSpacing : minColumnSpacing; + auto minorItemSpacing = orientation == winrt::Orientation::Vertical ? minRowSpacing : minColumnSpacing; auto itemSizeMinor = orientation == winrt::Orientation::Horizontal ? m_effectiveItemWidth : m_effectiveItemHeight; itemSizeMinor += minorItemSpacing;