Skip to content

Commit

Permalink
fix InvalidOperationException when items collection is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaeumlisberger committed Jan 23, 2024
1 parent 53bed11 commit eccd645
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/VirtualizingWrapPanel/VirtualizingWrapPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ private void FindStartIndexAndOffset()

if (startOffsetY <= 0)
{
startItemIndex = 0;
startItemIndex = Items.Count > 0 ? 0 : -1;
startItemOffsetX = 0;
startItemOffsetY = 0;
return;
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.3</Version>
<Version>2.0.4</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: #51 VirtualizingWrapPanel does not shrink when items are changed
- Fix: InvalidOperationException when items collection is empty
</PackageReleaseNotes>

<RootNamespace>WpfToolkit.Controls</RootNamespace>
Expand Down
9 changes: 9 additions & 0 deletions src/VirtualizingWrapPanelTest/Tests/BasisTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ public class BasisTest
{
private VirtualizingWrapPanel vwp = TestUtil.CreateVirtualizingWrapPanel(500, 400);

[UIFact]
public void NoItems()
{
vwp = TestUtil.CreateVirtualizingWrapPanel(500, 400, itemCount: 0);

Assert.Equal(0, vwp.DesiredSize.Width);
Assert.Equal(0, vwp.DesiredSize.Height);
}

[UIFact]
public void Inital()
{
Expand Down

0 comments on commit eccd645

Please sign in to comment.