MVC 在 Winform 中无法实现?

发布于 2024-09-13 08:27:21 字数 555 浏览 4 评论 0原文


基于经典 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

等数载,海棠开 2024-09-20 08:27:21

视图始终应该接收输入,即使它可以随后将请求委托给控制器。到目前为止,在我见过的 winforms MVC 应用程序中,会发生这种情况,并且控制器不是直接接收输入的

Windows 窗体设计者喜欢将控件的事件处理程序添加到窗体中本身,但您不必这样做。如果您愿意,您可以使用任何其他类来处理这些输入事件。

不过,我绝对推荐使用 MVP 方法。它的设置相对容易,到目前为止对我来说效果很好。

您可能想仔细阅读问题的答案“如何您在 WindowsForms 应用程序中实现 MVC 吗?” 了解更多信息。

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

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.

冬天旳寂寞 2024-09-20 08:27:21

你是正确的 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文