简体   繁体   English

C#中的MVC获胜。 表格申请

[英]MVC in c# win. form application

I 'am building a small windows form application. 我正在构建一个小的Windows窗体应用程序。

I have a View - a simple form that has some functionality in it. 我有一个View-一种简单的表单,其中包含一些功能。 a Controller - a class that will react to loading, saving, getting data from the model and prepare it form the view etc. a Model - a class that will get and save data to DB or file. Controller-一个类,将对从模型中加载,保存,获取数据并准备从视图等进行响应。Model-一个类,将获取并保存数据至DB或文件。

The controller is creating a form instance an run it, and creating a model instance when needed. 控制器正在创建表单实例并运行它,并在需要时创建模型实例。

I wonder about how to react in the controller to the view events. 我想知道如何在控制器中对视图事件做出反应。 Should I register to the view events (buttons click, combo change etc.) ? 我应该注册查看事件(按钮单击,组合更改等)吗? This will make the form controls visible outside the form? 这将使窗体控件在窗体外部可见吗?

Maybe I have a mistake in the design? 也许我的设计有误?

Microsoft has created a framework for Win Forms MVC applications, the Composite UI Application framework. Microsoft已经为Win Forms MVC应用程序创建了一个框架,即Composite UI Application框架。

http://www.codeplex.com/smartclient http://www.codeplex.com/smartclient

It is probably overkill for a small project, but you could look at it and get some ideas. 对于一个小型项目而言,这可能是过高的,但是您可以查看一下并获得一些想法。

如果您使用Google MVP(模型查看呈现器),则会发现有关如何在Windows窗体应用程序中实现关注点分离模式的信息。

您能看看在winforms中使用MVC MVP模式的 SO帖子吗?

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

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