开发者

Winforms or WPF MVC

All,

As far as I understand ASP.NET MVC is the framework that implements the MVC pattern released my Microsoft. I wonder why there is no Winforms or WPF MVC implementation ? The reason I am asking is that I am planning to start on a new big WinForms project and ideally we are looking for a framework that implements some kind 开发者_如何转开发of common pattern to improve the testability of our solution.

Thanks, MK


For WPF, the MVVM pattern is so deeply ingrained in the framework itself that you don't really see it until someone points it out to you. You don't really need a separate framework for that (although certain types, such as Josh Smith's RelayCommand, would be nice to have in the BCL).

Windows Forms isn't really going anywhere anymore, which is why you don't see any new or thriving MVC-style frameworks for that platform. However, patterns & practices' Composite Application Block (CAB) was an attempt at such a framework.

Most people found the CAB to be too complicated to their taste, but I personally found it a valuable effort, even if it could have been simpler to use. It's still out there and available in source code format, so you might want to take a look at it.

However, if at all possible, implement your application as a WPF application instead.


If you want to use WPF you should look into using the MVVM pattern (Model View View-Model).

There's a template you can download for Visual Studio for it. It's part of the WPF Toolkit I think. Look on CodePlex.com.

Hope this helps!


There are a few similar SO Questions here and here.

Just because there is not a strict framework for MVC in webforms/wpf doesn't mean you can't follow the principles and code in an MVC way. I think MVVM for WPF is similar although I have no experience of this.


  • As Tony said, read up on the Model-View-ViewModel pattern (essentially, this a variation of MVC, but better suited for the WPF programming model
  • Have a look at the Composite Application Library for WPF and Silverlight (from Microsoft P&P). I can say from experience that this library is a lot easier to use than the Composite Application Block...
  • The Caliburn Framework is also worth looking at


WinForms are dead. You better look at WPF+MVVM (+Prism)


What an excellent question asked here: Why isn't there an MVC equivalent framework for WPF? I spent 6 years on WPF platform only to find out:

  1. No further development on the WPF toolkit ever occurred since fist release.
  2. Hosting web browsers in WPF still has major air-space issues.
  3. Charting was never fully ported to WPF.
  4. VS2013 never was provided with an WPF MVVM template for new projects.
  5. Prism is confusing.
  6. Learning curve is steep.
  7. The open community hardly developed any open libs. like Javascript folks did.
  8. Running it as an in-browser app. was very difficult to get right.
  9. Compared to Web-Client rendering it is just plain slow.
  10. And perhaps worst of all Microsoft went quiet on us. Until just recently announcing they're back in the game, but if you look at their plans it looks more like a Sunset release than getting back in the game.

    The solution for me is to dump WPF in favor of MVC which I've done. MVC has its quirks but it's a much nicer platform than the cantankerous framework that's best suited using the "Relay Command" what a pile of nonsense.

Imagine your boss saying, hey we need that in a web browser and your reply "It'll be ready tomorrow"...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜