2
2
// The .NET Foundation licenses this file to you under the MIT license.
3
3
// See the LICENSE file in the project root for more information.
4
4
5
+ using System ;
5
6
using System . Collections . Generic ;
6
7
using System . Linq ;
7
8
using Windows . Foundation ;
@@ -152,7 +153,7 @@ protected override Size ArrangeOverride(Size finalSize)
152
153
if ( finalSize != DesiredSize )
153
154
{
154
155
// We haven't received our desired size. We need to refresh the rows.
155
- finalSize = UpdateRows ( finalSize ) ;
156
+ UpdateRows ( finalSize ) ;
156
157
}
157
158
158
159
if ( _rows . Count > 0 )
@@ -194,6 +195,7 @@ private Size UpdateRows(Size finalSize)
194
195
var position = new UvMeasure ( Orientation , Padding . Left , Padding . Top ) ;
195
196
196
197
var currentRow = new Row ( new List < UvRect > ( ) , default ) ;
198
+ var finalMeasure = new UvMeasure ( Orientation , width : 0.0 , height : 0.0 ) ;
197
199
void Arrange ( UIElement child , bool isLast = false )
198
200
{
199
201
var desiredMeasure = new UvMeasure ( Orientation , child . DesiredSize ) ;
@@ -222,6 +224,7 @@ void Arrange(UIElement child, bool isLast = false)
222
224
223
225
// adjust the location for the next items
224
226
position . U += desiredMeasure . U + spacingMeasure . U ;
227
+ finalMeasure . U = Math . Max ( finalMeasure . U , position . U ) ;
225
228
}
226
229
227
230
var lastIndex = Children . Count - 1 ;
@@ -241,10 +244,11 @@ void Arrange(UIElement child, bool isLast = false)
241
244
return Size . Empty ;
242
245
}
243
246
244
- var lastRowRect = _rows . Last ( ) . Rect . ToRect ( Orientation ) ;
245
- return new Size (
246
- lastRowRect . Bottom + Padding . Bottom ,
247
- lastRowRect . Right + Padding . Right ) ;
247
+ // Get max V here before computing final rect
248
+ var lastRowRect = _rows . Last ( ) . Rect ;
249
+ finalMeasure . V = lastRowRect . Position . V + lastRowRect . Size . V ;
250
+ var finalRect = finalMeasure . Add ( paddingEnd ) . ToSize ( Orientation ) ;
251
+ return finalRect ;
248
252
}
249
253
}
250
254
}
0 commit comments