MVVM中的控制器,如何从ViewModel获取信息到其控制器? [英] Controllers in MVVM, How to get info from viewmodel to it's controller?

查看:211
本文介绍了MVVM中的控制器,如何从ViewModel获取信息到其控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用MVVM模式构建应用程序,我们拥有使用DI连接所有视图和视图模型的控制器.我见过的所有MVVM示例都很简单,只有1个视图.视图模型如何/应该与控制器对话?控制器了解模型和视图,viewmodel是否应该将事件发送回控制器?应该在哪里保存?模型?控制器?

We are building an app using the MVVM pattern, we have controllers that wire up all the views and viewmodels using DI. All examples of MVVM I've seen are really simplistic and have 1 view. How do/should viewmodels talk back to the controller? The controller knows about the models and views, should the viewmodel send events back to the controller? Where should a save happen? Model? Controller?

推荐答案

我们也使用控制器,但在我们的情况下,它们负责应用程序的工作流程.控制器知道ViewModel和模型,但不知道具体的View,因为它将由IoC容器注入.

We use Controllers too but in our case they are responsible for the application workflow. The Controller knows the ViewModel and the Model but not the concrete View because this will be injected by the IoC Container.

如果您对仅显示一个以上UI(模式对话框,具有条件工作流程的向导)的示例感兴趣,那么您可以看看:

If you are interested in an example that shows more than just one UI (modal dialog, wizard with conditional workflow) then you might have a look at:

WPF应用程序框架(WAF)- http://waf.codeplex.com

WPF Application Framework (WAF) - http://waf.codeplex.com

这篇关于MVVM中的控制器,如何从ViewModel获取信息到其控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆