Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ObservableCollections/SynchronizedViewList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ private void Parent_ViewChanged(in SynchronizedViewChangedEventArgs<T, TView> e)
var oldIndex = listView.RemoveAt(e.OldStartingIndex);
var newIndex = listView.Insert(e.NewStartingIndex, e.NewItem.View);
OnCollectionChanged(e.WithNewAndOldStartingIndex(newStartingIndex: newIndex, oldStartingIndex: oldIndex));
return;
}
break;
case NotifyCollectionChangedAction.Reset: // Clear or drastic changes
listView.Clear(IterateFilteredIndexedViewsOfParent()); // clear and fill refresh
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
using System.Collections.Specialized;
using System.Diagnostics;
using ObservableCollections;

namespace ObservableCollections.Tests;
Expand Down Expand Up @@ -56,4 +58,25 @@ public void ToNotifyCollectionChanged_Filter()
e.Current.Should().Be("$4");
e.MoveNext().Should().BeFalse();
}
}

[Fact]
public void ToNotifyCollectionChanged_Move()
{
var list = new ObservableList<int> { 0, 1, 2, 3 };

var view = list.CreateView(i => i)
.ToNotifyCollectionChanged();

int moveEventCount = 0;

view.CollectionChanged += (_, e) =>
{
if (e.Action == NotifyCollectionChangedAction.Move)
moveEventCount++;
};

list.Move(0, 1);

moveEventCount.Should().Be(1);
}
}