Answered Prism architecture

  • Tuesday, May 22, 2012 5:27 PM
     
     

    Hello everybody,

    We're planning to develop a lightweight CRM (customers, orders, resources etc) application in WPF with Prism.v4. We already built a outlookbar-like usercontrol and use the microsoft ribbons. There exist additional regions, but these are the essential ones for this scenario.

    Furthermore there exists an infrastructure dll with all the models, repositories, interfaces etc etc.

    After some brainstorming we came up with the following fact:

    The customermodule needs nothing to know about the ordersmodule (the ordersmodule knows the customer models). But we want the usercomfort to load all orders which belong to a specific customer. So in customer-detail-mode (customer ribbontab and customer outlookbar items are injected) we want a ribbonbutton to navigate from "customer detail" to "this customers orders".

    The question is: how to achieve this without breaking the loose coupling?

    Our approach: giving the customer-ribbontab a region for other modules interaction with customers. Because the ordermodule defenitively knows about the customer (based on the 1:n relation from our datamodel).

    Thank you in advance

All Replies

  • Tuesday, May 22, 2012 8:43 PM
     
     

    Hi,

    I'm not sure if this answers your question (I think if im reading your problem right then it does) You need to give the modules in your app the ability to communicate with each other without them knowing about each other?

    PRISM ships with a component called the eventaggregator. Basically one view model subscribes to a particular event in the eventaggregator and has a method it executes each time its receives that message. Another module sends that message.

    so to make things a little clearer, your orders module will register to listen to the "LoadCustomerorders" event. when it receives it it will execute a method LoadCustomerOrders(int Customerid). at this point I should mention that with these events you can also pass a value of any type.

    In your customers module the user will select a button "load orders". In this command you will "publish" loadCustomerOrder and pass with it a customerid of 1.The orders modules receives that eventand loads the customers order.

    This way you still maintain the loose coupling but allow various modules to communicate witheach other.

    Its quite simple to use the eventaggregator and there are plenty of examples of this in the prism quickstarts and the web.

    I hope that answered your question? 

  • Wednesday, May 23, 2012 8:01 AM
     
     

    Thanks for your reply. That's all right. And I'm using the eventaggregator. And I know how to let modules communicate via events. The essential point is "In your customers module the user will select a button "load orders". From where comes this button? I don't want to touch my customersmodule if a new module appears (e.g. a billingmodule). So I have to inject these buttons somehow into the customermodule.

    Should I use a special region inside the customermodule's ribbontab for commands coming from other modules? To achieve some kind of "extension of the module"? Or are there any other solutions?

  • Wednesday, May 23, 2012 9:34 AM
     
     Answered

    Hi,

    I've never treid to do what you are doing right now. I've always been happy with "having a button" that publishes an event solutions.

    In your case I think your solution is sounds fine. If for example the ordersmodule, billinmodule etc they each send an custom object. Your customer module receives these custom objects which can contain things like event to execute etc. You create a datatemplate within your ribbon that converts these objects into buttons etc. Then when one is selected the event is fired and your order module handles that event.

  • Tuesday, May 29, 2012 5:33 AM
    Moderator
     
     

    Hi csteinmueller,

    How is your things going?


    Annabella Luo[MSFT]
    MSDN Community Support | Feedback to us

  • Monday, June 04, 2012 8:32 AM
    Moderator
     
     
    We are temporarily marking this as "Answer", if you have any concerns or new findings; please feel free to let me know.
    Best regards.

    Annabella Luo[MSFT]
    MSDN Community Support | Feedback to us