English 中文(简体)
MVP Connecting The Triads
原标题:
  • 时间:2009-12-16 12:36:28
  •  标签:
  • mvp

I have a main form with a left and right pane. The left pane displays a list of customers and I have a button the user clicks to show orders. When the user clicks this button I want to show the order details view described below in the right pane.

I have an order details form that will be displayed within the right pane of the main form and will show all the orders for the selected customer.

I have defined view interfaces for both views and there is a presenter for each view.

I want the order details to be able to get a hold of the selected customer so that it can obtain the orders for that customer.

How should I go about it? Event Aggregator? Composite Presenter?

最佳回答

Each pane is not a separate view. By doing that you are tying the specifics of the form to the presenter. The basic idea is that when you re editing a list of customers the presenter should not care how the form is setup.

Your two pane view should extract a list of customers from the presenter and use that list to fill out the left pane. Then when an item is clicked it asks the presenter for the list of orders the customers made and other details.

This approach will solve your problem as now there is a single view. When you click on something on the order and it needs to know the current customer you can refer to the tree view (or combo box, or list view, etc) to see what is the currently selected customer.

The trick to avoiding issues like this is to ask yourself what happens if I make a new form that uses completely different UI elements. Will the presenter have to be altered to reflect that? If the presenter does then you have tied it too closely to the implementation of the view.

问题回答

暂无回答




相关问题
Dependency Injection for Presenter

I have a Presenter that takes a Service and a View Contract as parameters in its constructor: public FooPresenter : IFooPresenter { private IFooView view; private readonly IFooService service;...

Convert to list a object with anonymous type

I need convert to list a object with anonymous type because when i databind the gridview i get "The data source does not support server-side data paging" or How i can solve this? object o = ...

MVP Connecting The Triads

I have a main form with a left and right pane. The left pane displays a list of customers and I have a button the user clicks to show orders. When the user clicks this button I want to show the order ...

Where do I store MVC/MVP and Service layer unit tests?

In MVC/MVP style applications that have Controller/Presenter classes within the Client Application assembly and then a Services layer assembly containing Service classes, where do people recommend ...

MVP, design question

I working on a MVP designed application and have some design questions. When writing code in the presenter-layer how should the communication go between different presenters/views? Lets say I have a ...

Session State with MVP and Application Controller patterns

I ve created an MVP (passive view) framework for development and decided to go for an Application Controller pattern to manage the navigation between views. This is targeted at WinForms, ASP.NET and ...

ASP.NET MVP Injecting Service Dependency

I have an ASP.NET page that implements my view and creates the presenter in the page constuctor. Phil Haack s post providing was used as the starting point, and I ll just the examples from the post ...

热门标签