CompositeCommands | Register and Unregister Strategy

Topics: Prism v4 - WPF 4
Jul 8, 2011 at 3:52 PM

Environment: Windows XP SP3, Visual Studio 2010 Ultimate, .NET 4.0, PRISM, MEF

We use RelayCommands for intermodule communication.

The modules register the commands in the ViewModel and unregister the commands in the EndModuleCommand called when the module is closed.

Is there an established  way to track the number of times a RelayCommand was registered by a module and disallow a second registration?


Jul 8, 2011 at 4:15 PM
Edited Jul 8, 2011 at 4:15 PM


You could create a service that tracks the number of times your RelayCommand was registered in each module, so that you allow/reject subsequent registrations.

About commanding, Prism supports DelegateCommands and CompositeCommands (for which you can read more in the Communication chapter of the Prism MSDN documentation). There's probably no limitation that would halt you from using RelayCommands in Prism, but there is no intentional integration between them an the Prism mechanisms for modularity, UI composition, and so forth.

Also, for matters specifically related to the RelayCommand functionality, you might find better support about it in the WPF forums.

I hope you find this helpful.

Guido Leandro Maliandi

Jul 8, 2011 at 4:23 PM

Thanks Guido - I was using Composite Commands. I wrote RelayCommands by mistake.

Is there any demo or implementation of the service for tracking registrations?

Jul 8, 2011 at 6:14 PM

Hi Ranjith,

The CompositeCommand class has a property called RegisteredCommands, which might be helpful for your scenario.

As of my knowledge, there are no code samples demonstrating this kind of service available.

I hope you find this helpful.

Guido Leandro Maliandi