c# - Subscribing to changes in a nested list with a property bound to a checkbox -
c# - Subscribing to changes in a nested list with a property bound to a checkbox -
i trying prevent user continuing until have selected @ to the lowest degree 1 item in list. list bound separate view command within main view , list viewmodel has bool 2 way binding checkbox in view. command go on part of main viewmodel seek , hear changes creating derived list
templist = this.whenanyvalue(x => x.items, (layers) => layers == null ? enumerable.empty<bool>() : layers.createderivedcollection(x => x.selected)) .toproperty(this, x => x.templist); cancontinue = this.whenanyvalue(m => m.collectioninfo, m => m.templist, (collectiondatabase, tempitems) => { if (collectiondatabase == null || tempitems == null) homecoming false; var temp = tempitems.any(x => x == true); homecoming temp; });
the problem templist never changes. can see selected property changing on kid viewmodel that's it.
i have tried assigning templist as
templist = items.changed.select(_ => items.select(gr => gr.selected)) .toproperty(this, x => x.templist);
anyone have suggestions? info model out of command in real application i'm loading sets of info disk can contain 1 or more sets of data. i've got sample app demonstrates issue if want seek yourself.
i managed solve it, of import bits set changetrackingenabled = true on reactivelist , subscribe itemchanged notification collection, means templist no longer needed either. changed predicate command utilize int number of selected items.
var cancontinue = this.whenanyvalue(x => x.numselected, num => num > 0); this.whenanyobservable(x => x.items.itemchanged) .subscribe(_ => numselected = items.count(i => i.selected));
c# reactiveui
Comments
Post a Comment