I have done a limited amount of Windows Forms development, especially when compared to ASP.NET. I don’t feel like I have ever truly done it right, there has always been an uncomfortable amount of duplicate code and way too much crap in the UI.
I am working on a side project that uses Windows Forms and I want to do it right, but I have been having a hard time finding good guidance on how to best architect a Windows Forms presentation layer.
Most of the Windows Forms books I have browsed through focus almost completely on the technology details (how to databind, how to show a dialog, etc), not how to best implement it. Patterns and Practices has some decent guidance in this area, but I keep hoping to find something more comprehensive. (This would be a great book opportunity for someone)
Here are some of the things I have found useful so far:
- patternshare.org – A massive wiki collecting patterns and examples of how to implement them. The only problem with this site is that it is difficult to navigate and find what you are looking for.
- Composite UI Application Block – Looks promising, definitely the most relevant piece from P&P.
- User Interface Process Application Block – The most often recommended way to implement MVC in Windows Forms. (Good Article on testing with UIP, patternshare link)
- Model View Presenter – A good MSDN article that details a simple way to implement MVP. (this is the kind of stuff I am really looking for)
- Jason Kemp has a great post on implementing the command pattern.
Any Windows Forms developers want to chime in with some other good resources?

I'd forget about using UIPAB for Windows Forms development if I were you. It's too buggy and lacking to use in Windows Forms as it was created for Web Forms applications.
I think Model View Presenter is best if you have an object model behind your views.
But what really matters is sticking to the pattern, because if you cut corners, it gonna get unmaintainable. My project has some lazy developers who develop 'outside' the pattern because abiding to the pattern is 'inconvenient' and the code base has simply become unmaitainable as a code base that uses the UIPAB.
I'd recommend also checking out Fowler's Presentation Model pattern as well. After trying a few implementations using MVP, I found Presentation Model to be much easier while still providing reusability and forms that were dirt simple. For instance, it was easy to utilize the presentation model components in some automated FitNesse testing we had on top of our NUnit tests. Avoiding unnecessary interfaces for dialogs and forms was a nice thing IMO.
This advise is not so much patterns oriented. I have developed for both Windows based forms and ASP.net forms and by far I have found ASP hardest because one must cover more presentation cases. But I don't think your problem is as specific as Windows Forms vs. ASP.net. I think it is an aesthetics issue. What presentation pattern works better as a desktop app vs as a web app. It might be helpfull to expand your search in those terms. Once you know what works on general aesthetic level I think the .net implementation should be much simpler.
Wow!
Thanks, James.
I agree there isn't a lot of good info on architecting a Windows Forms GUI; what I've learned is through trial and error and paying attention to everything I can for some ideas I can use.
I'm not sure there are that many WinForms shops out there right now. Whenever I'm around fellow .NET nerds, I'm often the only one who does Windows-only development. Then they start talking database access and HttpHandlers, and I stop listening :)
We've made mistakes in our UI that are really painful and we're regretting them all the time. One of the downsides of choosing the Windows Forms route is that you HAVE to get it right the first time because deployment is so much harder.
Charles Petzold had a post about Visual Studio rotting the mind a while ago; I think he's on to something. Many of the mistakes I see are a result of starting out with the Form in the designer and coding down, as opposed to starting at the data and business object level and coding up.
I'm curious to know what you find in your hunt. :)
Martin Fowler just updated his UI patterns, so there is definitely some good stuff here worth checking out.
http://martinfowler.com/eaaDev/
Another vote for Presentation Model. Be strict. The *only* thing a view (e.g. a Form class) should do is update itself from the PresentationModel and handle user input by calling command-style methods on the PresentationModel. We test drive the PresentationModel and wiring up the UI is invariably a cinch...
Have fun!
My two cents go to the Presentation Model too.
I have refactored the CAB Smart Part Quick Start sample to MVP and PM and added unit tests. Souce code is ready for comparision at:
http://yysun.wbeditor.com/?p=33