c# - ReactiveUI SelectMany form of CreateDerivedCollection -
using reactiveui 6.5, i'm trying achieve selectmany linq expression createderivedcollection feature of rxui. objects in source collection (type 'a') have isselected
property, collection property items of type 'b'. want end ireactivederivedlist<b>
flattened list of of b objects a's selected. makes sense.
to make little more concrete, let's use example of app browsing log files. have logfileviewmodel
type , our main screen's view model has list of these. each instance in list represents log file on system, , present list of these user can select. it's multi-select list can select more 1 @ time.
the logfileviewmodel
has isselected
boolean property, set true/false user selects or deselects corresponding item in list. , has property list<logentry>
. each logentry
object of course represents 1 entry in corresponding log file.
what want have reactive list in main view model list of of logentry
objects of selected logfileviewmodel
objects. reactivelist of selected log files easy, i'm stuck on second part. here's main view model like:
public class mainviewmodel { public mainviewmodel() { //this gets initialized log files somehow, doesn't matter logfiles = new list<logfileviewmodel(...); selectedlogfiles = logfiles.createderivedcollection(l => l, l => l.isselected); selectedlogfileentries = ? //how create one? } public list<logfileviewmodel> logfiles { get; private set; } public ireactivederivedlist<logfileviewmodel> selectedlogfiles { get; private set; } public ireactivederivedlist<logentry> selectedlogfileentries { get; private set; } }
is there known way i'm not seeing? if not, clever ideas achieve behavior? :-)
edit : looks missed this question in initial search. paul provided "clever" solution problem 2 years ago. question ... still best way achieve behavior?
Comments
Post a Comment