<p>I've found <a href="http://blogs.msdn.com/priozersk/archive/2007/08/06/implementing-mvc-pattern-in-net-cf-applications-part-1.aspx" rel="noreferrer">an article</a> on this subject by a Microsoft employee, but has anyone implemented a more robust framework for this? Is there a lightweight framework for WinForms that could be ported easily? I'd like to get up to speed fairly quickly and avoid producing a framework/library of my own to handle this when someone smarter has already done this. </p>

<p>I haven't looked at the <a href="http://msdn.microsoft.com/en-us/library/aa480471.aspx" rel="noreferrer">Mobile Software Factory</a> from the P&amp;P group, but I suspect it's kind of heavy. Is it worth a look?</p>

<p><strong>Edit: I'm not looking for information on the ASP.NET MVC project. I'm asking about the compact framework 'WinForms' implementation, and how to implement MVC with that.</strong></p>

[{'answer_id': 26371, 'author': 'Kevin Pang', 'author_id': 1574, 'author_profile': 'https://Stackoverflow.com/users/1574', 'pm_score': -1, 'selected': False, 'text': '<p><strong>Edit: The above posters are correct.  I saw MVC and immediately thought of web forms.  My apologies.  Feel free to disregard this.  I\'ll leave my original message in place just in case anyone who <em>is</em> interested in web forms MVC needs the links. :-)</strong></p>\n\n<p>There are a couple MVC frameworks out there, neither of which are very "lightweight", but MVC is a pretty big shift away from web forms so that is expected:</p>\n\n<ul>\n<li><a href="http://www.asp.net/mvc/" rel="nofollow noreferrer">ASP.NET MVC</a> - This is Microsoft\'s attempt at an MVC framework.  It is still in preview mode so use it at your own discretion, but several people are already using it in their production applications.  You will find ample documentation on this with a simple Google search as it is becoming very popular amongst the .NET crowd.</li>\n<li><a href="http://www.castleproject.org/MonoRail/" rel="nofollow noreferrer">Castle MonoRail</a> - The MonoRail framework is an open-source MVC framework that has been around for quite some time and is in use on several production applications.  It is definitely more flushed out than the ASP.NET MVC framework, but considering the amount of effort Microsoft is throwing at their MVC offering, I think will change relatively soon.</li>\n</ul>\n'}, {'answer_id': 26392, 'author': 'Brian Warshaw', 'author_id': 1344, 'author_profile': 'https://Stackoverflow.com/users/1344', 'pm_score': 2, 'selected': False, 'text': "<p>Neither of you (davidg or Kevin Pang) paid attention to the fact that he's interested in <em>WinForms</em>, not <em>Web Forms</em>. He wants a framework that pushes the Model-View-Controller design pattern (davidg, MVC isn't just the name of an ASP.NET framework) in a WinForms project using the .NET Compact Framework. He asked his question just fine.</p>\n"}, {'answer_id': 26399, 'author': 'FlySwat', 'author_id': 1965, 'author_profile': 'https://Stackoverflow.com/users/1965', 'pm_score': 1, 'selected': False, 'text': "<p>@DavidG and @KevenPang</p>\n\n<p>MVC is not limited to a web technology, in fact the original smalltalk MVC was for desktop applications.</p>\n\n<p>It works like this:</p>\n\n<ul>\n<li>View = Client Form</li>\n<li>Controller = Wraps up Client Events and marshals between View and Model</li>\n<li>Model = Application Data and Business Logic</li>\n</ul>\n\n<p>In pure Smalltalk MVC, the View is not limited to being a form, but can be any representation of Model Data...For example, if we had a Model that represented a spreadsheet, we could have the following views:</p>\n\n<ul>\n<li>SpreadSheet View</li>\n<li>Printer Friendly View</li>\n<li>Icon View</li>\n</ul>\n\n<p>etc, the Model would be the same, but the View would create a different output object in each case.</p>\n\n<p>All that said, I don't know if such a framework exists for the .NET Compact framework, I just wanted to point out that MVC does not mean WebApp.</p>\n"}, {'answer_id': 26423, 'author': 'Quibblesome', 'author_id': 1143, 'author_profile': 'https://Stackoverflow.com/users/1143', 'pm_score': 4, 'selected': True, 'text': '<p>I personally think that the Mobile Software Factory doesn\'t hold much joy for CF.\nWe still use one part of it (EventBroker) at work and I\'d like to even remove that part if possible (as it doesn\'t support generic events and you have to cast the arguments into their strong types from EventArgs). A sister project at work used it for part of their UI but had to rip it out due to performance issues (another big project, although that has additional performance issues of it\'s own as well).</p>\n\n<p>The issue I find with the MVP framework that the P&amp;P lib offers is that Forms and Controls OWN presenters instead of Presenters/Controllers owning Forms (who didn\'t read "It\'s just a view" : Pragmatic Programmer?). \nThis fits beautifully with MS\'s "Form First" rapid application development mantra but it sucks when you consider how expensive windows handles can be in CE (if you have a lot of them).\nWe run a very large CF application at work and we\'ve rolled our own MVC framework. It\'s not hard to roll your own, just make sure you separate everything out into Controllers, Views, Business Objects and Services and have a UIController that controls the interactions between the controllers. </p>\n\n<p>We actually go one step further and re-use forms/controls by using a Controller->View->Layout pattern.\nThe controller is the same as usual, the view is the object that customises a layout into a particular view and the layout is the actual UserControl. We then swap these in and out of a single Form. This reduces the amount of Windows Controls we use dramatically.\nThis + initialising all of the forms on start-up means that we eradicate the noticable pause that you get when creating new Windows Controls "on-demand".</p>\n\n<p>Obviously it only really pays to do this kind of thing if you are rolling a large application. We have roughly 20 + different types of View which use in total about 7 different layouts. This hurts our initialisation routine (as we load the forms at start up) by a magnitude of about 10 seconds but psychologically most users are willing to accept such a hit at start up as opposed to noticeable pauses during run-time.</p>\n\n<p>The main issue with the P&amp;P library in my books is that it is a FF -> CF port and due to certain incompatability and performance differences between the two platforms you lose a lot of useful functionality.</p>\n\n<p>Btw, <a href="http://ctrl-shift-b.blogspot.com/2007/08/interactive-application-architecture.html" rel="nofollow noreferrer">this</a> is by far and away the most comprehensive article i\'ve ever read on MVC/MVP.\nFor Windows application (desktop or CE) I\'d recommend using the Taligent Model-View-Presenter version without the interactions, commands and selections (e.g the controller/presenter performs all the work).</p>\n'}, {'answer_id': 252128, 'author': 'ctacke', 'author_id': 13154, 'author_profile': 'https://Stackoverflow.com/users/13154', 'pm_score': 0, 'selected': False, 'text': '<p>Take a look at <a href="http://www.windowsmobilemvc.com/" rel="nofollow noreferrer">mFly\'s Mobile MVC</a>. I\'ve never used it, but it\'s pitched as a reasonable MVC framework for the CF.</p>\n'}, {'answer_id': 277246, 'author': 'Johann Gerell', 'author_id': 6345, 'author_profile': 'https://Stackoverflow.com/users/6345', 'pm_score': 0, 'selected': False, 'text': '<p>@davidg: "Why would you want MVC on Compact Framework?"</p>\n\n<p>Why not? It\'s not like it\'s reserved for web dev, it\'s a pattern.</p>\n'}, {'answer_id': 4215459, 'author': 'ctacke', 'author_id': 13154, 'author_profile': 'https://Stackoverflow.com/users/13154', 'pm_score': 2, 'selected': False, 'text': '<p>There\'s also the <a href="http://ioc.codeplex.com" rel="nofollow">OpenNETCF IoC framework</a> (which I don\'t think existed when this question was asked) which is much lighter, but similar in object model to the P&amp;P\'s Mobile Software Factory.</p>\n'}]
['https://Stackoverflow.com/questions/26355', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/636/']