Browse Source

Added missing Materialized event invocation.

In TreeContainerIndex. Also add TODO concerning ItemContainerEventArgs.
pull/620/merge
Steven Kirk 10 years ago
parent
commit
4e9fe88c27
  1. 4
      src/Avalonia.Controls/Generators/ItemContainerEventArgs.cs
  2. 8
      src/Avalonia.Controls/Generators/TreeContainerIndex.cs
  3. 7
      src/Avalonia.Controls/Generators/TreeItemContainerGenerator.cs

4
src/Avalonia.Controls/Generators/ItemContainerEventArgs.cs

@ -27,6 +27,10 @@ namespace Avalonia.Controls.Generators
/// </summary>
/// <param name="startingIndex">The index of the first container in the source items.</param>
/// <param name="containers">The containers.</param>
/// <remarks>
/// 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?
/// </remarks>
public ItemContainerEventArgs(
int startingIndex,
IList<ItemContainerInfo> containers)

8
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
/// <summary>
/// Removes a set of containers from the index.
/// </summary>
/// <param name="startingIndex">The index of the first item.</param>
/// <param name="containers">The item containers.</param>
public void Remove(IEnumerable<ItemContainerInfo> containers)
public void Remove(int startingIndex, IEnumerable<ItemContainerInfo> 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()));
}
/// <summary>

7
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<ItemContainerInfo> Clear()
{
var items = base.Clear();
Index.Remove(items);
Index.Remove(0, items);
return items;
}
public override IEnumerable<ItemContainerInfo> Dematerialize(int startingIndex, int count)
{
Index.Remove(GetContainerRange(startingIndex, count));
Index.Remove(startingIndex, GetContainerRange(startingIndex, count));
return base.Dematerialize(startingIndex, count);
}
public override IEnumerable<ItemContainerInfo> RemoveRange(int startingIndex, int count)
{
Index.Remove(GetContainerRange(startingIndex, count));
Index.Remove(startingIndex, GetContainerRange(startingIndex, count));
return base.RemoveRange(startingIndex, count);
}

Loading…
Cancel
Save