@@ -445,7 +445,7 @@ protected override Size MeasureOverride(Size constraint)
445
445
// appears in Auto column.
446
446
//
447
447
448
- MeasureCellsGroup ( extData . CellGroup1 , constraint , false , false ) ;
448
+ MeasureCellsGroup ( extData . CellGroup1 , false , false ) ;
449
449
double rowSpacing = RowSpacing ;
450
450
double columnSpacing = ColumnSpacing ;
451
451
double combinedRowSpacing = RowSpacing * ( RowDefinitions . Count - 1 ) ;
@@ -458,9 +458,9 @@ protected override Size MeasureOverride(Size constraint)
458
458
if ( canResolveStarsV )
459
459
{
460
460
if ( HasStarCellsV ) { ResolveStar ( DefinitionsV , innerAvailableSize . Height ) ; }
461
- MeasureCellsGroup ( extData . CellGroup2 , innerAvailableSize , false , false ) ;
461
+ MeasureCellsGroup ( extData . CellGroup2 , false , false ) ;
462
462
if ( HasStarCellsU ) { ResolveStar ( DefinitionsU , innerAvailableSize . Width ) ; }
463
- MeasureCellsGroup ( extData . CellGroup3 , innerAvailableSize , false , false ) ;
463
+ MeasureCellsGroup ( extData . CellGroup3 , false , false ) ;
464
464
}
465
465
else
466
466
{
@@ -470,7 +470,7 @@ protected override Size MeasureOverride(Size constraint)
470
470
if ( canResolveStarsU )
471
471
{
472
472
if ( HasStarCellsU ) { ResolveStar ( DefinitionsU , innerAvailableSize . Width ) ; }
473
- MeasureCellsGroup ( extData . CellGroup3 , innerAvailableSize , false , false ) ;
473
+ MeasureCellsGroup ( extData . CellGroup3 , false , false ) ;
474
474
if ( HasStarCellsV ) { ResolveStar ( DefinitionsV , innerAvailableSize . Height ) ; }
475
475
}
476
476
else
@@ -487,7 +487,7 @@ protected override Size MeasureOverride(Size constraint)
487
487
double [ ] group2MinSizes = CacheMinSizes ( extData . CellGroup2 , false ) ;
488
488
double [ ] group3MinSizes = CacheMinSizes ( extData . CellGroup3 , true ) ;
489
489
490
- MeasureCellsGroup ( extData . CellGroup2 , innerAvailableSize , false , true ) ;
490
+ MeasureCellsGroup ( extData . CellGroup2 , false , true ) ;
491
491
492
492
do
493
493
{
@@ -498,20 +498,20 @@ protected override Size MeasureOverride(Size constraint)
498
498
}
499
499
500
500
if ( HasStarCellsU ) { ResolveStar ( DefinitionsU , innerAvailableSize . Width ) ; }
501
- MeasureCellsGroup ( extData . CellGroup3 , innerAvailableSize , false , false ) ;
501
+ MeasureCellsGroup ( extData . CellGroup3 , false , false ) ;
502
502
503
503
// Reset cached Group2Widths
504
504
ApplyCachedMinSizes ( group2MinSizes , false ) ;
505
505
506
506
if ( HasStarCellsV ) { ResolveStar ( DefinitionsV , innerAvailableSize . Height ) ; }
507
- MeasureCellsGroup ( extData . CellGroup2 , innerAvailableSize , cnt == c_layoutLoopMaxCount , false , out hasDesiredSizeUChanged ) ;
507
+ MeasureCellsGroup ( extData . CellGroup2 , cnt == c_layoutLoopMaxCount , false , out hasDesiredSizeUChanged ) ;
508
508
}
509
509
while ( hasDesiredSizeUChanged && ++ cnt <= c_layoutLoopMaxCount ) ;
510
510
}
511
511
}
512
512
}
513
513
514
- MeasureCellsGroup ( extData . CellGroup4 , constraint , false , false ) ;
514
+ MeasureCellsGroup ( extData . CellGroup4 , false , false ) ;
515
515
516
516
gridDesiredSize = new Size (
517
517
CalculateDesiredSize ( DefinitionsU ) + ColumnSpacing * ( DefinitionsU . Count - 1 ) ,
@@ -979,27 +979,23 @@ private void ApplyCachedMinSizes(double[] minSizes, bool isRows)
979
979
980
980
private void MeasureCellsGroup (
981
981
int cellsHead ,
982
- Size referenceSize ,
983
982
bool ignoreDesiredSizeU ,
984
983
bool forceInfinityV )
985
984
{
986
- MeasureCellsGroup ( cellsHead , referenceSize , ignoreDesiredSizeU , forceInfinityV , out _ ) ;
985
+ MeasureCellsGroup ( cellsHead , ignoreDesiredSizeU , forceInfinityV , out _ ) ;
987
986
}
988
987
989
988
/// <summary>
990
989
/// Measures one group of cells.
991
990
/// </summary>
992
991
/// <param name="cellsHead">Head index of the cells chain.</param>
993
- /// <param name="referenceSize">Reference size for spanned cells
994
- /// calculations.</param>
995
992
/// <param name="ignoreDesiredSizeU">When "true" cells' desired
996
993
/// width is not registered in columns.</param>
997
994
/// <param name="forceInfinityV">Passed through to MeasureCell.
998
995
/// When "true" cells' desired height is not registered in rows.</param>
999
996
/// <param name="hasDesiredSizeUChanged">When the method exits, indicates whether the desired size has changed.</param>
1000
997
private void MeasureCellsGroup (
1001
998
int cellsHead ,
1002
- Size referenceSize ,
1003
999
bool ignoreDesiredSizeU ,
1004
1000
bool forceInfinityV ,
1005
1001
out bool hasDesiredSizeUChanged )
@@ -1066,14 +1062,14 @@ private void MeasureCellsGroup(
1066
1062
foreach ( DictionaryEntry e in spanStore )
1067
1063
{
1068
1064
SpanKey key = ( SpanKey ) e . Key ;
1069
- double requestedSize = ( double ) e . Value ! ;
1065
+ double desiredSize = ( double ) e . Value ! ;
1070
1066
1071
1067
EnsureMinSizeInDefinitionRange (
1072
1068
key . U ? DefinitionsU : DefinitionsV ,
1073
1069
key . Start ,
1074
1070
key . Count ,
1075
- requestedSize ,
1076
- key . U ? referenceSize . Width : referenceSize . Height ) ;
1071
+ key . U ? ColumnSpacing : RowSpacing ,
1072
+ desiredSize ) ;
1077
1073
}
1078
1074
}
1079
1075
}
@@ -1193,8 +1189,8 @@ private static double GetMeasureSizeForRange(
1193
1189
measureSize +=
1194
1190
spacing +
1195
1191
( definitions [ i ] . SizeType == LayoutTimeSizeType . Auto ?
1196
- definitions [ i ] . MinSize :
1197
- definitions [ i ] . MeasureSize ) ;
1192
+ definitions [ i ] . MinSize :
1193
+ definitions [ i ] . MeasureSize ) ;
1198
1194
} while ( -- i >= start ) ;
1199
1195
1200
1196
return measureSize ;
@@ -1228,20 +1224,23 @@ private static LayoutTimeSizeType GetLengthTypeForRange(
1228
1224
/// <summary>
1229
1225
/// Distributes min size back to definition array's range.
1230
1226
/// </summary>
1227
+ /// <param name="definitions">Array of definitions to process.</param>
1231
1228
/// <param name="start">Start of the range.</param>
1232
1229
/// <param name="count">Number of items in the range.</param>
1233
- /// <param name="requestedSize">Minimum size that should "fit" into the definitions range.</param>
1234
- /// <param name="definitions">Definition array receiving distribution.</param>
1235
- /// <param name="percentReferenceSize">Size used to resolve percentages.</param>
1230
+ /// <param name="spacing"><see cref="ColumnSpacing"/> or <see cref="RowSpacing"/></param>
1231
+ /// <param name="desiredSize">Minimum size that should "fit" into the definitions range.</param>
1236
1232
private void EnsureMinSizeInDefinitionRange (
1237
1233
IReadOnlyList < DefinitionBase > definitions ,
1238
1234
int start ,
1239
1235
int count ,
1240
- double requestedSize ,
1241
- double percentReferenceSize )
1236
+ double spacing ,
1237
+ double desiredSize )
1242
1238
{
1243
1239
Debug . Assert ( 1 < count && 0 <= start && ( start + count ) <= definitions . Count ) ;
1244
1240
1241
+ // The spacing between definitions that this element spans through must not be distributed
1242
+ double requestedSize = Math . Max ( ( desiredSize - spacing * ( count - 1 ) ) , 0.0 ) ;
1243
+
1245
1244
// avoid processing when asked to distribute "0"
1246
1245
if ( ! MathUtilities . IsZero ( requestedSize ) )
1247
1246
{
0 commit comments