简体   繁体   中英

Recommendations for new a C# WPF MVC project

I'm developing a system using WPF 4. I pretend to use MVC in development.

I never used MVC before, so I'm a little confused about concepts. Some time (ages) ago I develop some Delphi software more or less with that scheme:

  1. a thin client application to be installed in several machines that talk with the...
  2. ...server application that talks with the thin clients and is the only that connects to database.

In that new project, I pretend develop that thin client (the View part of MVC) using WPF, but the another pieces I'm unsure what I need do. By example: 1. The "Model" part will be my Server application, but the "Controller" will work on the client or server machine?
2. How I do the communication between server and client in that case? sockets? remoting?
3. What you recommend? There is some "Basic Sample" that kind of project to download and to study?

I thank you any light here :)

MVVM (Model View View Model) is a MVC-like design patern that is very well suited to WPF and Silverlight development, in part because of its focus on binding, at which Xaml is highly functional.

As for client-server communication, WCF services is the recommended approach these days.

There are many introductory articles out there on MVVM client, WCF communication based applications. Here's one sample that I learned off of myself:

http://calcium.codeplex.com/

Additionally, there are many MVVM frameworks out there available for WPF. A couple are:

MVVM Light (simple and easy to get started with):

http://www.galasoft.ch/mvvm/getstarted/

Caliburn (highly functional and feature rich):

http://caliburn.codeplex.com/

+1 to jeffn, as the MVC pattern in WPF is called MVVM. It is a variation on the pattern that mixes very well with the binding infrastructure of WPF.

Your "client" app would contain models, views and viewmodels (models, views, and controllers). You wouldn't try to split the pattern across the server/client boundary. It isn't practical and saves you nothing. If there is any code sharing between the client and the server it would be the Models.

Here's a scenario:

  1. User clicks on a button requesting a list of users. The button is bound to a property of type ICommand on the ViewModel. The button click fires the Execute method of ICommand, which the ViewModel interprets as a request for users.

  2. The ViewModel connects to the server via a WCF service. The server gathers all users into instances of type User and sends these back across the wire.

  3. The ViewModel then takes these deserialized User instances and places them in an ObservableCollection. This collection is bound to a ListControl in the UI.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM