diff --git a/Toolkit.Foundation/ObservableCollection.cs b/Toolkit.Foundation/ObservableCollection.cs index 57709cb..2876e9b 100644 --- a/Toolkit.Foundation/ObservableCollection.cs +++ b/Toolkit.Foundation/ObservableCollection.cs @@ -289,7 +289,7 @@ public partial class ObservableCollection : if (selectable.Selected) { SelectedItem = item; - SelectedIndex = this.IndexOf(item); + SelectedIndex = IndexOf(item); } } } @@ -312,6 +312,7 @@ public partial class ObservableCollection : return Task.CompletedTask; } + public Task Handle(ReplaceEventArgs args) { if (args.Value is TItem item) @@ -332,6 +333,11 @@ public partial class ObservableCollection : return Task.CompletedTask; } + public Task Handle(SelectionEventArgs args) + { + return Task.CompletedTask; + } + public int IndexOf(TItem item) => collection.IndexOf(item); @@ -378,6 +384,7 @@ public partial class ObservableCollection : return true; } + public bool Move(int index, TItem item) { int oldIndex = collection.IndexOf(item); @@ -408,7 +415,7 @@ public partial class ObservableCollection : { return false; } - + Disposer.Dispose(item); Disposer.Remove(this, item); @@ -490,7 +497,7 @@ public partial class ObservableCollection : partial void OnSelectedIndexChanged(int oldValue, int newValue) { - if (oldValue >= 0 && oldValue <= this.Count -1 && this[oldValue] is ISelectable removed) + if (oldValue >= 0 && oldValue <= this.Count - 1 && this[oldValue] is ISelectable removed) { removed.Selected = false; } @@ -501,9 +508,12 @@ public partial class ObservableCollection : } } - public Task Handle(SelectionEventArgs args) + partial void OnSelectedItemChanged(TItem? oldValue, TItem? newValue) { - return Task.CompletedTask; + if (oldValue is ISelectable selectable) + { + selectable.Selected = false; + } } }