Skip to content

Commit 8570e3c

Browse files
committed
added comments
1 parent b40f014 commit 8570e3c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Microsoft.Toolkit.Uwp.UI.Controls.Primitives/StaggeredLayout/StaggeredLayout.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,15 @@ protected override Size MeasureOverride(VirtualizingLayoutContext context, Size
147147
double availableWidth = availableSize.Width;
148148
double availableHeight = availableSize.Height;
149149

150+
// This ternary prevents the column width from being NaN, which would otherwise cause an exception when measuring item sizes
150151
double columnWidth = double.IsNaN(DesiredColumnWidth) ? availableWidth : Math.Min(DesiredColumnWidth, availableWidth);
151152
if (columnWidth != state.ColumnWidth)
152153
{
153154
// The items will need to be remeasured
154155
state.Clear();
155156
}
156157

158+
// This ternary prevents the column width from being NaN, which would otherwise cause an exception when measuring item sizes
157159
state.ColumnWidth = double.IsNaN(DesiredColumnWidth) ? availableWidth : Math.Min(DesiredColumnWidth, availableWidth);
158160
int numColumns = Math.Max(1, (int)Math.Floor(availableWidth / state.ColumnWidth));
159161

0 commit comments

Comments
 (0)