简体   繁体   English

有关新的C#WPF MVC项目的建议

[英]Recommendations for new a C# WPF MVC project

I'm developing a system using WPF 4. I pretend to use MVC in development. 我正在使用WPF 4开发系统。我假装在开发中使用MVC。

I never used MVC before, so I'm a little confused about concepts. 我以前从未使用过MVC,因此我对概念有些困惑。 Some time (ages) ago I develop some Delphi software more or less with that scheme: 一段时间(年龄)以前,我或多或少地使用该方案开发了一些Delphi软件:

  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. 在这个新项目中,我假装使用WPF开发该瘦客户机(MVC的View部分),但是我不确定其他我需要做什么。 By example: 1. The "Model" part will be my Server application, but the "Controller" will work on the client or server machine? 例如:1.“模型”部分将是我的服务器应用程序,但是“控制器”将在客户端或服务器计算机上工作?
2. How I do the communication between server and client in that case? 2.在这种情况下,服务器与客户端之间如何通信? sockets? 插座? remoting? 远程处理?
3. What you recommend? 3.您推荐什么? 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. MVVM(模型视图视图模型)是一种类似于MVC的设计模式,非常适合WPF和Silverlight开发,部分原因在于Xaml在功能上非常注重绑定。

As for client-server communication, WCF services is the recommended approach these days. 对于客户端与服务器之间的通信,最近推荐使用WCF服务。

There are many introductory articles out there on MVVM client, WCF communication based applications. 关于MVVM客户端,基于WCF通信的应用程序,有很多介绍性文章。 Here's one sample that I learned off of myself: 这是我从中学到的一个示例:

http://calcium.codeplex.com/ http://calcium.codeplex.com/

Additionally, there are many MVVM frameworks out there available for WPF. 此外,还有许多可用于WPF的MVVM框架。 A couple are: 几个是:

MVVM Light (simple and easy to get started with): MVVM Light(简单易上手):

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

Caliburn (highly functional and feature rich): Caliburn(功能强大且功能丰富):

http://caliburn.codeplex.com/ http://caliburn.codeplex.com/

+1 to jeffn, as the MVC pattern in WPF is called MVVM. +1到jeffn,因为WPF中的MVC模式称为MVVM。 It is a variation on the pattern that mixes very well with the binding infrastructure of WPF. 这是模式的一种变体,与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. 该按钮绑定到ViewModel上ICommand类型的属性。 The button click fires the Execute method of ICommand, which the ViewModel interprets as a request for users. 单击按钮将触发ICommand的Execute方法,ViewModel将该方法解释为对用户的请求。

  2. The ViewModel connects to the server via a WCF service. ViewModel通过WCF服务连接到服务器。 The server gathers all users into instances of type User and sends these back across the wire. 服务器将所有用户收集到类型为User的实例中,并通过网络将这些用户发送回去。

  3. The ViewModel then takes these deserialized User instances and places them in an ObservableCollection. 然后,ViewModel接受这些反序列化的User实例,并将其放置在ObservableCollection中。 This collection is bound to a ListControl in the UI. 该集合绑定到UI中的ListControl。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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