Composite Command

Topics: Prism v4 - WPF 4
Nov 16, 2011 at 6:30 PM
Edited Nov 16, 2011 at 6:37 PM

Hi,

I have a question regarding the usage of CompositeCommand.

Let me describe the situation:

I have a module that is managing the workspaces (WorkspaceManager). A workspace is a folder that contains several files. These files are associated with various child modules. A workspace can be loaded, saved, etc. Obviously, the child modules are directly impacted by a workspace loading operation (they have to load their own files from the folder).

In order to address this need, I was thinking of using CompositeCommand: the WorkspaceManager is exposing the load/save CompositeCommands. The child modules are registering their child DelegateCommand (load / save) with the CompositeCommands of the WorkspaceManager in order to do the specific loading.

Another option can consist in using events (shared service events or through EventAggregator) but it seems less adapted to this situation (in particular because it's asynchronous).

What is your thoughts on this issue? 

Thanks a lot,

Best

Developer
Nov 17, 2011 at 12:37 PM

Hi,

Based on my understanding of your scenario, CompositeCommand seems a reasonable approach if you expect an immediate action from the UI. This is explained in more depth in the Communicating Between Loosely Coupled Components chapter of the Prism documentation at MSDN. From the documentation:

(...)

The Prism Library provides the following communication approaches:

  •      Solution commanding. Use when there is an expectation of immediate action from the user interaction.
  •      Region context. Use this to provide contextual information between the host and views in the host's region. This approach is somewhat similar to the DataContext, but it does not     rely on it.
  •      Shared services. Callers can call a method on the service which raises an event to the receiver of the message. Use this if none of the preceding is applicable.
  •      Event aggregation. For communication across view models, presenters, or controllers when there is not a direct action-reaction expectation.

(...)

Regards,

Agustin Adami
http://blogs.southworks.net/aadami


Nov 17, 2011 at 6:30 PM

Hi Augustin,

Thanks for your quick answer that confirms my thoughts.

I have another question regarding the module settings but I will start another discussion for that soon.

Thanks again,
Best,

Le 17 nov. 2011 13:37, "aadami" <notifications@codeplex.com> a écrit :

From: aadami

Hi,

Based on my understanding of your scenario, CompositeCommand seems a reasonable approach if you expect an immediate action from the UI. This is explained in more depth in the Communicating Between Loosely Coupled Components chapter of the Prism documentation at MSDN. From the documentation:

(...)

The Prism Library provides the following communication approaches:

  • Solution commanding. Use when there is an expectation of immediate action from the user interaction.
  • Region context. Use this to provide contextual information between the host and views in the host's region. This approach is somewhat similar to the DataContext, but it does not rely on it.
  • Shared services. Callers can call a method on the service which raises an event to the receiver of the message. Use this if none of the preceding is applicable.
  • Event aggregation. For communication across view models, presenters, or controllers when there is not a direct action-reaction expectation.

(...)

Regards,

Agustin Adami
http://blogs.southworks.net/aadami


Read the full discussion online.

To add a post to this discussion, reply to this email (CompositeWPF@discussions.codeplex.com)

To start a new discussion for this project, email CompositeWPF@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe on CodePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at CodePlex.com