MVC 在 Winform 中无法实现?
基于经典 MVC 模式的定义,控制器负责处理用户输入并与模型交互,并确定要渲染的视图。
MVC 的维基百科定义:
“控制器接收输入并通过调用模型对象来启动响应。控制器接受来自用户的输入并指示模型和视口根据该输入执行操作。”
根据定义,是不是不能通过.NET winforms来实现MVC呢?因为视图始终应该接收输入,即使它可以随后将请求委托给控制器。 到目前为止,在我所见过的 winforms MVC 应用程序中,就会发生这种情况,并且控制器不是直接接收输入并确定要呈现哪个视图的控制器。
对我来说,似乎所有 winforms MVC 实现都是 MVP 的不同变体,而不是 MVC。
(我知道 ASP.NET MVC 遵循经典 MVC 定义,因为控制器首先通过路由引擎接收输入,然后确定要呈现哪个视图等。)
有人可以吗阐明? 谢谢。
Based on the definition of classic MVC pattern, Controller is responsible for handling user inputs and interacting with Models and also determining which View to be rendered.
Wikipedia definition of MVC:
"The controller receives input and initiates a response by making calls on model objects. A controller accepts input from the user and instructs the model and viewport to perform actions based on that input."
According the definition, is it not possible to implement MVC through .NET winforms? Because it's always the View that should recieve the input, even though it can delegate the request to Controller afterwards.
In the winforms MVC applications that I have seen so far, this is what happens and the Controller is NOT the one that receives the input directly and determines which View to be rendered.
To me, it seems like all winforms MVC implementations are different variations of MVP and NOT MVC.
(I understand the fact that ASP.NET MVC adheres to classic MVC definition as the controller first receives input through the routing engine, and then determines which View to be rendered etc..)
Can someone clarify?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Windows 窗体设计者喜欢将控件的事件处理程序添加到窗体中本身,但您不必这样做。如果您愿意,您可以使用任何其他类来处理这些输入事件。
不过,我绝对推荐使用 MVP 方法。它的设置相对容易,到目前为止对我来说效果很好。
您可能想仔细阅读问题的答案“如何您在 WindowsForms 应用程序中实现 MVC 吗?” 了解更多信息。
The Windows Forms designer likes to add event handlers for the controls to the form itself, but you don't have to do it this way. You could use any other class to handle those input events if you wish.
I would definitely recommend using an MVP approach, however. It's relatively easy to set up and has worked out great for me so far.
You may want to read through the answers to the question "How would you implement MVC in a WindowsForms application?" for more information.
你是正确的 MVP 模式适用于 Winforms,而且效果很好。一位朋友有一个使用 winform 的项目,他在其中应用了 mvp 模式。
我不确定,但我认为 MVC 不能应用于 Winforms,因此我认为人们转向了 MVP 的不同变体。
You are correct MVP pattern is applicable to Winforms, and it works great. A friend had a project with winforms, where he applied the mvp pattern.
I am not sure but I think that MVC cannot be applied to Winforms, and for that reason i think people turned to the different variations of MVP.