|
|
|
@ -27,6 +27,7 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
private readonly IList _inner; |
|
|
|
private NotifyCollectionChangedEventHandler? _collectionChanged; |
|
|
|
private NotifyCollectionChangedEventHandler? _preCollectionChanged; |
|
|
|
private NotifyCollectionChangedEventHandler? _postCollectionChanged; |
|
|
|
private bool _listening; |
|
|
|
|
|
|
|
@ -70,7 +71,7 @@ namespace Avalonia.Controls |
|
|
|
/// Gets a value that indicates whether the items source can provide a unique key for each item.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// TODO: Not yet implemented in Avalonia.
|
|
|
|
/// Not implemented in Avalonia, preserved here for ItemsRepeater's usage.
|
|
|
|
/// </remarks>
|
|
|
|
internal bool HasKeyIndexMapping => false; |
|
|
|
|
|
|
|
@ -92,6 +93,25 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when a collection has finished changing and all <see cref="CollectionChanged"/>
|
|
|
|
/// event handlers have been notified.
|
|
|
|
/// </summary>
|
|
|
|
internal event NotifyCollectionChangedEventHandler? PreCollectionChanged |
|
|
|
{ |
|
|
|
add |
|
|
|
{ |
|
|
|
AddListenerIfNecessary(); |
|
|
|
_preCollectionChanged += value; |
|
|
|
} |
|
|
|
|
|
|
|
remove |
|
|
|
{ |
|
|
|
_preCollectionChanged -= value; |
|
|
|
RemoveListenerIfNecessary(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Occurs when a collection has finished changing and all <see cref="CollectionChanged"/>
|
|
|
|
/// event handlers have been notified.
|
|
|
|
@ -229,6 +249,7 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
void ICollectionChangedListener.PreChanged(INotifyCollectionChanged sender, NotifyCollectionChangedEventArgs e) |
|
|
|
{ |
|
|
|
_preCollectionChanged?.Invoke(this, e); |
|
|
|
} |
|
|
|
|
|
|
|
void ICollectionChangedListener.Changed(INotifyCollectionChanged sender, NotifyCollectionChangedEventArgs e) |
|
|
|
@ -241,22 +262,6 @@ namespace Avalonia.Controls |
|
|
|
_postCollectionChanged?.Invoke(this, e); |
|
|
|
} |
|
|
|
|
|
|
|
internal void AddListener(ICollectionChangedListener listener) |
|
|
|
{ |
|
|
|
if (Inner is INotifyCollectionChanged incc) |
|
|
|
{ |
|
|
|
CollectionChangedEventManager.Instance.AddListener(incc, listener); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
internal void RemoveListener(ICollectionChangedListener listener) |
|
|
|
{ |
|
|
|
if (Inner is INotifyCollectionChanged incc) |
|
|
|
{ |
|
|
|
CollectionChangedEventManager.Instance.RemoveListener(incc, listener); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Retrieves the index of the item that has the specified unique identifier (key).
|
|
|
|
/// </summary>
|
|
|
|
|