我正在使用ReactiveUI 4.1
。我使用ReactiveCollection
个可选项(具有IsSelected
标志)作为另一个派生反应集合的源,该集合使用过滤器仅查看具有IsSelected == true
的项目。如果在创建派生集合之前预先填充了一些未/选定项目的源集合,则视图过滤器似乎可以工作,但是当稍后源集合中的项目从选定状态变为未选定状态时,这些项目不会“消失”派生的集合。我在所有集合上都将ChangeTrackingEnabled
标记设置为true
,但它似乎没有帮助。附上我的代码段:
private readonly ReactiveCollection<string> _sourceItems = new ReactiveCollection<string>();
private readonly ReactiveCollection<SelectableDataItem<string>> _selectableItemsView = null;
private readonly ReactiveCollection<SelectableDataItem<string>> _selectedItemsView = null;
private readonly ReactiveCollection<string> _selectedDataView = null;
///....
this._sourceItems.ChangeTrackingEnabled = true;
this._selectableItemsView =
this.SourceItems.CreateDerivedCollection<string, SelectableDataItem<string>>(i => new SelectableDataItem<string>(i) { IsSelected = true, });
this._selectableItemsView.ChangeTrackingEnabled = true;
this._selectedItemsView =
this._selectableItemsView.CreateDerivedCollection<SelectableDataItem<string>, SelectableDataItem<string>>(
i => i,
f => f.IsSelected,
(i1, i2) => 0
);
this._selectedItemsView.ChangeTrackingEnabled = true;
this._selectedDataView =
this._selectableItemsView.CreateDerivedCollection<SelectableDataItem<string>, string>(i => i.Data, f => f.IsSelected, (i1, i2) => 0);
this._selectedDataView.ChangeTrackingEnabled = true;
答案 0 :(得分:0)
嗯,看起来像个错误 - 你可以做以下其中一个: