Skip to content

Commit e910407

Browse files
committed
fix non-fixed star column width measurement
The child elements in non-fixed Start columns should get always double.PositiveInfinity width on its Measure call, because the column.ActualCurrentWidth at the Measure phase may be narrow than the finalRect.Width in Arrange phase.
1 parent 294786d commit e910407

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

components/DataTable/src/DataTable/DataRow.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,11 @@ protected override Size MeasureOverride(Size availableSize)
131131

132132
double width = column.ActualCurrentWidth;
133133

134-
if (column.IsAuto && !column.IsFixed)
134+
if (column.IsFixed)
135+
{
136+
child.Measure(new Size(width, availableSize.Height));
137+
}
138+
else
135139
{
136140
// We should get the *required* width from the child.
137141
child.Measure(new Size(double.PositiveInfinity, availableSize.Height));
@@ -142,15 +146,11 @@ protected override Size MeasureOverride(Size availableSize)
142146

143147
// If the adjusted column width is smaller than the current cell width,
144148
// we should call DataTable.MeasureOverride() again to extend it.
145-
if (!(width >= childWidth))
149+
if (column.IsAuto && !(width >= childWidth))
146150
{
147151
_parentTable.InvalidateMeasure();
148152
}
149153
}
150-
else
151-
{
152-
child.Measure(new Size(width, availableSize.Height));
153-
}
154154

155155
maxHeight = Math.Max(maxHeight, child.DesiredSize.Height);
156156
}

components/DataTable/src/DataTable/DataTable.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ protected override Size ArrangeOverride(Size finalSize)
238238
width = starUnit * column.DesiredWidth.Value;
239239

240240
// Store the actual star column width.
241+
//Debug.WriteLine($" Column[{i}] ({column.DesiredWidth}) width is re-adjusted to: {width}");
241242
column.CurrentWidth = width;
242243
}
243244

0 commit comments

Comments
 (0)