Hi all,
This is our first project with ReactiveUI - after a lot of lurking around and watching commits in GitHub and comments on this list we finally get to use ReactiveUI in anger :)
We are working on a GUI where we plan to have several "modules" on screen at once - sort of a simple dashboard. Each module can surface some tabs that I want to display in a ribbon at the top of the screen - this is a ReactiveCollection<RibbonTab> property on the module. The modules inherit from ReactiveObject.
Additionally, the "host" of the modules can also have its own ribbon tabs. At the moment I'm looking to have a ViewModel called HostViewModel and a view called HostView.
The HostViewModel will have its own private set of tabs which is in a property defined as
ReactiveCollection<RibbonTab> HostTabs - this is what the host wants to display
The HostViewModel also has a collection defined as
ReactiveCollection<ScreenModule> Modules
There's a complimentary property called ActiveModule (of type ScreenModule) to signify which module (if any!) is active. Any non-active module is still on screen but is smaller.
I'd like to combine into a single ReactiveCollection
a) The RibbonTabs exposed by the HostViewModel's HostTabs property
b) The RibbonTabs exposed from the module pointed at by the ActiveModule property. Noting that there may be no ActiveModule, or that there could be one but its RibbonTabs collection is empty
c) The RibbonTabs exposed by ScreenModules that aren't active
They should be in that order. Extra RibbonTabs could be added by the Host at any time. The ActiveModule could change to another module (or disappear entirely) - this would involve swapping around tabs (and an activated module may choose to add more tabs too).
Is this too complicated for a simple CreateDerivedCollection() call? I was thinking that if used WhenAny() to listen for changes to the HostTabs.Count property, plus the ActiveModule property, I could create an Observable that would fire whenever the list of tabs needed to be recalculated and pass that to the second overload of CreateDerivedCollection. However, on what object do I call the CreateDerivedCollection extension method? It filters and transforms the collection on which it is called - I'm looking for a way to create that initial collection.
Would it be best to use my WhenAny() Observable to just loop through and rebuild/reorder a ReactiveCollection<> in a simple loop over the three different RibbonTab collections? I reckon I can code this without too much fuss (I'd prefer to reorder elements rather than blow away the complete collection and have it rebuilt) but I'm not sure if there's a better way and I'm just missing it.
I'm using ReactiveUI v4.6.1 (whatever the just released version is) from NuGet - I'm avoiding the v5 stuff at the moment as per Paul's advice since it's still a bit of a moving target and I couldn't get the NuGet package working properly anyway.
Thanks for your help!
Cheers,
Ian