Browse Source

Don't try to realize index -1.

`Algorithm_GetAnchorForTargetElement` can return -1 and when it does so we try to realize that item, which obviously doesn't exist, so boom.
pull/4698/head
Steven Kirk 5 years ago
parent
commit
08a8badd7a
  1. 2
      src/Avalonia.Layout/FlowLayoutAlgorithm.cs

2
src/Avalonia.Layout/FlowLayoutAlgorithm.cs

@ -211,7 +211,7 @@ namespace Avalonia.Layout
anchorPosition = new Point(anchorBounds.X, anchorBounds.Y);
}
}
else
else if (anchorIndex >= 0)
{
// It is possible to end up in a situation during a collection change where GetAnchorForTargetElement returns an index
// which is not in the realized range. Eg. insert one item at index 0 for a grid layout.

Loading…
Cancel
Save