Skip to content

Commit

Permalink
fix exception when changing the items collection while bringing conta…
Browse files Browse the repository at this point in the history
…iner into view
  • Loading branch information
sbaeumlisberger committed Feb 4, 2024
1 parent c100d42 commit 515bb9a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
12 changes: 12 additions & 0 deletions src/VirtualizingWrapPanel/VirtualizingWrapPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@ protected override Size MeasureOverride(Size availableSize)

ItemContainerManager.IsRecycling = IsRecycling;

if(bringIntoViewItemIndex >= Items.Count)
{
bringIntoViewItemIndex = -1;
bringIntoViewContainer = null;
}

MeasureBringIntoViewContainer(InfiniteSize);

Size newViewportSize;
Expand Down Expand Up @@ -192,6 +198,12 @@ protected override Size ArrangeOverride(Size finalSize)
{
ViewportSize = finalSize;

if (bringIntoViewItemIndex >= Items.Count)
{
bringIntoViewItemIndex = -1;
bringIntoViewContainer = null;
}

ArrangeBringIntoViewContainer();

foreach (var cachedContainer in ItemContainerManager.CachedContainers)
Expand Down
4 changes: 2 additions & 2 deletions src/VirtualizingWrapPanel/VirtualizingWrapPanel.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<PropertyGroup>
<title>VirtualizingWrapPanel</title>
<Version>2.0.4</Version>
<Version>2.0.5</Version>
<Authors>S. Bäumlisbergerr</Authors>
<Copyright>© S. Bäumlisberger</Copyright>
<Description>Implementation of a VirtualizingWrapPanel for WPF.</Description>
Expand All @@ -36,7 +36,7 @@
<PackageReadmeFile>README.md</PackageReadmeFile>

<PackageReleaseNotes>
- Fix: InvalidOperationException when items collection is empty
- Fix: Exception when changing the items collection while bringing container into view
</PackageReleaseNotes>

<RootNamespace>WpfToolkit.Controls</RootNamespace>
Expand Down

0 comments on commit 515bb9a

Please sign in to comment.