ReactiveProperty使用時に、Add, Deleteは反映されるのに ObservableCollection.Move だけは ReadOnlyReactiveCollection に反映されなくて困ったので対応方法のメモ
TL;DR
第二引数に Scheduler.CurrentThread
を指定するのを忘れないこと。
moveSupportedCollection.ToReadOnlyReactiveCollection(s.ToCollectionChanged<string>(), Scheduler.CurrentThread);
本家の実装例
以下のようになっている。
ReadOnlyReactiveCollectionTest.cs#L174
[TestMethod]
public void MoveTest()
{
var s = new MoveSupportCollection<string>();
s.Add("a");
s.Add("b");
var target = s.ToReadOnlyReactiveCollection(s.ToCollectionChanged<string>(), Scheduler.CurrentThread);
target.Is("a", "b");
s.Move(1, 0);
target.Is("b", "a");
}
原因
TODO: 分かり次第更新予定
参考
referencesource/observablecollection.cs at master · Microsoft/referencesource
↑ 途中もしかして ObservableCollection はMoveでは通知がされないのかと勘違いしましたが、当然ながら通知される実装になっています。