0

I implement MVP pattern in my windows forms application. As you know there is 1:1 means there is one presenter for one view.

So basically we can have:

public class MainPresenter
{
       IMainView _mainView;
       public MainPresenter(IMainView mainView)
       {
             _myView = myView;
       }
}

My question is can one presenter use other presenter. For instance:

public class MainPresenter
{
       IMainView _mainView;
       ISomeOtherPresenter _otherPresenter;
       public MainPresenter(IMainView mainView, IOtherPresenter otherPresenter)
       {
             _mainView = myView;
             _otherPresenter = otherPresenter;
       }
}

I am asking this question because i have main form from where there are buttons to open other forms/user controls. Means that from my understanding if main view is MainView and OtherView can be accessed through the button click from MainView, to me i should use his presenter in the MainPresenter (of course by injecting it).

If that's not the case could you show example based on my code to show how to open form from other form correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.