diff --git a/src/Avalonia.Controls/Generators/ItemContainerEventArgs.cs b/src/Avalonia.Controls/Generators/ItemContainerEventArgs.cs
index 6821a842e3..d361abfbfc 100644
--- a/src/Avalonia.Controls/Generators/ItemContainerEventArgs.cs
+++ b/src/Avalonia.Controls/Generators/ItemContainerEventArgs.cs
@@ -27,6 +27,10 @@ namespace Avalonia.Controls.Generators
///
/// The index of the first container in the source items.
/// The containers.
+ ///
+ /// TODO: Do we really need to pass in StartingIndex here? The ItemContainerInfo objects
+ /// have an index, and what happens if the contains passed in aren't sequential?
+ ///
public ItemContainerEventArgs(
int startingIndex,
IList containers)
diff --git a/src/Avalonia.Controls/Generators/TreeContainerIndex.cs b/src/Avalonia.Controls/Generators/TreeContainerIndex.cs
index e0c52beb11..08c11e2965 100644
--- a/src/Avalonia.Controls/Generators/TreeContainerIndex.cs
+++ b/src/Avalonia.Controls/Generators/TreeContainerIndex.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
namespace Avalonia.Controls.Generators
{
@@ -68,8 +69,9 @@ namespace Avalonia.Controls.Generators
///
/// Removes a set of containers from the index.
///
+ /// The index of the first item.
/// The item containers.
- public void Remove(IEnumerable containers)
+ public void Remove(int startingIndex, IEnumerable containers)
{
foreach (var container in containers)
{
@@ -77,6 +79,10 @@ namespace Avalonia.Controls.Generators
_containerToItem.Remove(container.ContainerControl);
_itemToContainer.Remove(item);
}
+
+ Dematerialized?.Invoke(
+ this,
+ new ItemContainerEventArgs(startingIndex, containers.ToList()));
}
///
diff --git a/src/Avalonia.Controls/Generators/TreeItemContainerGenerator.cs b/src/Avalonia.Controls/Generators/TreeItemContainerGenerator.cs
index 8a70aa7307..923d24775f 100644
--- a/src/Avalonia.Controls/Generators/TreeItemContainerGenerator.cs
+++ b/src/Avalonia.Controls/Generators/TreeItemContainerGenerator.cs
@@ -3,6 +3,7 @@
using System;
using System.Collections.Generic;
+using System.Linq;
using Avalonia.Controls.Templates;
using Avalonia.Data;
@@ -102,19 +103,19 @@ namespace Avalonia.Controls.Generators
public override IEnumerable Clear()
{
var items = base.Clear();
- Index.Remove(items);
+ Index.Remove(0, items);
return items;
}
public override IEnumerable Dematerialize(int startingIndex, int count)
{
- Index.Remove(GetContainerRange(startingIndex, count));
+ Index.Remove(startingIndex, GetContainerRange(startingIndex, count));
return base.Dematerialize(startingIndex, count);
}
public override IEnumerable RemoveRange(int startingIndex, int count)
{
- Index.Remove(GetContainerRange(startingIndex, count));
+ Index.Remove(startingIndex, GetContainerRange(startingIndex, count));
return base.RemoveRange(startingIndex, count);
}