Search code examples
c#mvppassive-view

My presenter needs to prompt the user for more information. How do I wire it up?


I'm working with the Passive View pattern. The user clicks a new account button. The view delegates responsibility to the presenter using parameterless method calls.

The problem is there are multiple account types so the user needs to pick which one they want to create. How do I resolve this?

  1. Create a new form from the view, get the needed information and expose it as a property so the presenter can retrieve it. (This ignores the notion that the view shouldn't have any logic in it)
  2. Create and use the new form from the presenter. (This ties the presenter directly to a form, ignoring the entire point of MVP)
  3. Create the new form somewhere else and pass it in as a constructor argument to the presenter... or view.
  4. Forget it and add a new button for each account type. (There are a number of account types and this will clutter the UI but so be it.)
  5. I'm going about this the wrong way and need to rethink my design. (If this is the case, an nudge in the the right direction would be appreciated.)

Solution

  • My solution for this was different than I expected. I changed the button the user clicked to a DropDownMenuButton. Then I passed a string list of account types to the view which populates the drop down menu. I also created an event handler for the drop down menu item click event, which updates a public property with the name of the menu item then delegates everything else to the presenter.

    The presenter just has to get the menu item name from the exposed property and then lookup the account type in a private dictionary of account types using the account type name as the key.