Hello, I could use some more advice regarding this approach. In a nutshell, I don't know how to make my DelegateCommands active when the tab associated with the command's view/viewmodel becomes the active tab.
To provide a little background, I have set up a globally available CompositeCommand, and my viewmodel instances are each registering local DelegateCommands (as per the above post). In a TabbedMdiContainer I have multiple views of the same type (each with their own viewmodel instance). I need to set this up so that when the CompositeCommand is called, only the view/viewmodel associated with the active tab responds.
For example, if each tab has a listbox with an item selected, when the user clicks the 'delete this item' button that is linked to my CompositeCommand, only the tab the user is looking at should respond by deleting its selected item. The listboxes in the other tabs should not be changed.
I think that I need to implement IActiveAware on the viewmodel. The viewmodel would then set the DelegateCommand's IsActive property when the tab associated with that view/viewmodel becomes the active tab. Finally, I'd declare the CompositeCommands with monitorCommandActivity set to true so that CanExecute will only be checked when the delegate command is active.
I guess the problem is that I don't know how best to associate each tab with a view/viewmodel. For example, if the viewmodel subscribes to the LastActiveDocumentChanged event (see: http://www.actiprosoftware.com/support/forums/viewforumtopic.aspx?ForumTopicID=3820), how does it know whether its view lives in the active document?