AKornich
AKornich

Reputation: 902

ReactiveUI 4.1 CreateDerivedCollection(...) filter does not seem to work

I am using ReactiveUI 4.1. I use a ReactiveCollection of selectable items (having IsSelected flag) as a source for another derived reactive collection that uses filter to view only items that have IsSelected == true. If the source collection is pre-populated with some un/selected items before creating the derived collection, the view filter seems to work, but when later on items in the source collection go from selected to unselected state these items do not "disappear" within the derived collection. I do set ChangeTrackingEnabled flag to true on all of the collection, but it does not seem to help. Attaching my code snippet:

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;

Upvotes: 0

Views: 888

Answers (1)

Ana Betts
Ana Betts

Reputation: 74654

Hmmm, looks like a bug - can you do one of the following:

  • Create a sample app that hits this bug, then create an issue
  • (Even better) Create a pull request against ReactiveUI with a test that fails

Upvotes: 0

Related Questions