Functionality CompositeCommand should have

Topics: Prism v4 - Silverlight 4, Prism v4 - WPF 4
Oct 4, 2012 at 4:33 PM

I think it is strange that the default behavior for a CompositeCommand is AND logic, i.e. that the command can only execute if all the commands can execute.

There should be a setting for the mode perhaps that allows you to select between OR and AND logic.

AND - command can execute only if all can execute, and all commands execute when executed (like it is now)

OR - command can execute if any can execute and all execute that can if executed

Developer
Oct 4, 2012 at 5:58 PM

Hi Alan,

As far as I know, this functionality is already supported by the CompositeCommand as out of the box. You can find more information about the CompositeCommand and how to use it in the following blog post:

Regards,

Damian Cherubini
http://blogs.southworks.net/dcherubini

Oct 4, 2012 at 6:33 PM

Well that's cool, I didn't even know that.  In my defense, I read the documentation which doesn't say that at all:

It reads...

"Return Value

truetrue (True in Visual Basic) if all of the commands return truetrue (True in Visual Basic); otherwise, falsefalse (False in Visual Basic)."

 

This is exactly what I need though, I have a Export menu command which each view/viewmodel implements differently. I only want the active one to be executed. My views and viewmodels are already IActiveAware so all I need to do is toggle the IsActive of the corresponding DelegateCommands it sounds like and add them to a composite command.. I'll give it a try!