Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7908637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:02:25+00:00 2026-06-03T12:02:25+00:00

I have implemented the MVP pattern in a few WinForms applications that uses a

  • 0

I have implemented the MVP pattern in a few WinForms applications that uses a passive view. I implement an interface containing properties and delegates in the form of Action< T > and Func< T > to wire up UI events in concrete views and call back to the presenter.

I am about to start a new project and did a little research into the pattern online including the many examples of the pattern here and notice that the all use EventHandler to notify presenters.

I don’t really understand why events would be used in this case, since I see a view as only having one presenter.

My question is, is this for the sake of remaining consistent with how the .Net framework uses events, or for some other reason that I am not seeing?

Here is a trivial example of the pattern I use:

public interface IViewAbstraction
{
    public ModelData ModelData { set; }
    public Action<ModelData> ModelDataChangedCallback { set; }
}

public class SomeWinForm : Form, IViewAbstraction
{
    private Action<ModelData> modelDataChanged;
    private ModelData model;

    public ModelData ModelData
    {
        set { /* when this property changes, update UI */ }
    }

    public Action<ModelData> ModelDataChangedCallback
    {
        set { modelDataChanged = value; }
    }

    private void OnSomeWinformsEvent(EventArgs args)
    {
        if (modelDataChanged == null) throw new Exception();

        modelDataChanged(model);
    }
}

public class Presenter
{
    private readonly IViewAbstraction view;
    private readonly IDataLayerAbstraction dataLayer;

    public Presenter(IViewAbstraction view, IDataLayerAbstraction dataLayer)
    {
        this.dataLayer = dataLayer;
        this.view = view;
        this.view.ModelDataChangedCallback = OnModelChanged;
        this.view.ModelData = dataLayer.GetData();
    }

    private void OnModelChanged(ModelData data)
    {
        // validate and save data.
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T12:02:26+00:00Added an answer on June 3, 2026 at 12:02 pm

    Your pattern is essentially the same as using events, with a key difference. Events don’t expose the underlying delegate (ModelDataChangedCallback in your example). Exposing this is bad practice as other code can clear the invocation list for example. An event will have an underlying delegate that can be added to or removed from, but never cleared from outside the scope of the class.

    I don’t understand your point about not having multiple subscribers – this isn’t a reason to not use events. An event is just a way for a class to say “Hey! This thing has happened”, a 1-to-1 mapping with a Presenter object is perfectly reasonable and normal.

    You also don’t end up with that rather odd looking write-only property in the view.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a small application that I have written that uses the MVP pattern
Have you ever seen someone try to implement the MVP pattern with ASP.NET Web
I am developing a large-ish application in WPF/WCF/NHibernate/etc. and have implemented the MVP pattern
I have written a MVP project where the View is a WinForm that implements
I'm trying to implement an MVP pattern using STL and I have used *shared_ptr*
I am trying to implement the MVP pattern for WINFORMS. Its a simple for
I have implemented one application in android which uses epublib to view .epub files.
I have a MVP application implemented. Back button is working fine. I'd like to
I have implemented an ASP.NET http handler. It appears to me that there is
I am thinking about implementing a user interface according to the MVP pattern using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.