Like any MVVM WPF app I have a handful of view models. Each has a few commands. My view implements a Fluent UI (Office ribbon) so there are some items that light up based on the context of the application. The ribbon is a child to the main application.
The basic structure of my app is that it manages a COURSE. A COURSE has multiple MODULES in it, so I have a VM for course & module... and each has commands.
When the app loads I set the data context of the main window to the course so binding the course commands to the ribbon is easy and works fine.
The challenge comes when the user starts to work with a module. When a module is selected from a list the details are shown in another user control. Now... my challenge is how to wire up the commands to the ribbon.
I assume I could have some event handler that programatically wires up the current module's commands to all the relevant controls in the ribbon and removes everything when the context goes away. But that seems like a lot of unnecessary work. Is there a cleaner way of doing this?
I thought about routed commands/events, but someone told me that this wouldn't work because they won't bubble all thew ay up to the Window and back down to the ribbon.
Looking for some guidance here... I'm a bit of a noob to MVVM (but loving it!).