Avatar of iulianchira
iulianchira
 asked on

Implementing MVC with Windows Forms

Where can I find a good example on how to completely implement the MVC pattern in Windows Forms. I found many tutorials and code examples on various sites (e.g. CodeProject, .NetHeaven) but many are more representative for the observer pattern than MVC. The application I want to develop is very simple, for a school project so I am not eager to use MVC frameworks like PureMVC.
Project ManagementC#Programming

Avatar of undefined
Last Comment
iulianchira

8/22/2022 - Mon
philipjonathan

I don't have a complete example, but just want to comment on the observer pattern part. I think it is normal to have the observer pattern, because the relationship between the model and the view is actually observer pattern itself.

Another thing is that you can't really get MVC in Windows Forms, because in pure MVC, the user action is actually handled by the Controller, but in Windows Forms, this is handled by the UI control through event (eg. Button1_Click event handler). So you can just think of the event handler as the Controller component.
Bob Learned

I have seen a lot of examples for Model-View-Controller and Model-View-Presenter code, so we can find plenty of examples, like this one:

Florida.NET User Group a Success -- Thanks Dave Noderer
http://weblogs.asp.net/scottcate/archive/2006/09/13/Florida.NET-User-Group-a-Success-_2D002D00_-Thanks-Dave-Noderer.aspx
iulianchira

ASKER
In my MVC application I do not want to instantiate the Control in my View and simple have something like MyControll.DoStuff(); in each event handler. I want to decouple things as much as possible.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Bob Learned

OK, since you have total control over that, then what is the problem?  Decoupling is the very nature that drives selecting MVC/MVP.  

Your class can define the View, and attach event handlers, without having that done in the UI.
ASKER CERTIFIED SOLUTION
iulianchira

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
iulianchira

ASKER
This question should not be deleted, moreover I provided an answer myself.
iulianchira

ASKER
iulianchira has requested that this question be closed (see the Alert Box above for more details). The question will be closed on 7/19/2009 if there are no objections.


I did not request for the question to be closed. I just said that I provided an answer myself.
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.