什么是我的控制器在我的应用程序与MVVM设计模式 [英] What are my controller in my application with a MVVM design pattern

查看:160
本文介绍了什么是我的控制器在我的应用程序与MVVM设计模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开发了一个WPF应用程序。我有一个mainwindow继承自Window,tabcontrol和许多tabitems在这个tabcontrol继承自UserControl。每个tabitem都有自己的cs文件,我在C#中编写所有的businesslogic,以及一个XAML文件,其中UI的开发完成。我也有一个SQL Server与数据库,我连接到槽LINQ。

I have developed a WPF-application. I have a mainwindow which inherit from Window, a tabcontrol and many tabitems in this tabcontrol which inherit from UserControl. Every tabitem has its own cs-file, where I code in C# all the businesslogic, and a XAML-file where the development of the UI is done. I also have a SQL Server with a database which i connect to trough LINQ.

所以我必须写我的选择在我的应用程序中使用哪个控制器。这是我困惑,因为我没有手动编程控制器,我认为ViewModel将在我的情况下像一个控制器。这是正确的吗?

So i have to write about my choice of which controller i use in my application. This is where i get confused, since i havent manually programmed a controller and i thought the ViewModel would behave like a controller in my case. Could this be correct? Can the ViewModel behave like a controller?

推荐答案

控制器可以向其相关视图发送命令改变视图对模型的呈现(例如,通过滚动文档)。它还可以向模型发送命令以更新模型的状态(例如,编辑文档)。 Model_View_Controller

A controller can send commands to its associated view to change the view's presentation of the model (e.g., by scrolling through a document). It can also send commands to the model to update the model's state (e.g., editing a document). Model_View_Controller

viewmodel 是一个视图模型,意思是它是视图的抽象,也用于视图和作为视图目标的模型之间的调解数据绑定。它可以被看作是控制器(在MVC模式中)的特定方面,该控制器用作将模型信息改变为视图信息并将命令从视图传递到模型中的转换器。视图模型公开了公共属性,命令和抽象。 Model_View_ViewModel

The viewmodel is a "model of the view" meaning it is an abstraction of the view that also serves in mediating between the view and the model which is the target of the view data bindings. It could be seen as a specialized aspect of what would be a controller (in the MVC pattern) that acts as a converter that changes model information into view information and passes commands from the view into the model. The view model exposes public properties, commands, and abstractions. Model_View_ViewModel

引入 MVVMC (MVC + MVVM)是必要的,如果你想驱动许多类似的View-ViewModel(用例)对。然后可以引入控制器。 Model_View_ViewModel_Controller

The introduction of MVVMC (MVC + MVVM) is nessesary in cases you would like to drive many similar pairs of View-ViewModel (use cases). You can then introduce controllers. Model_View_ViewModel_Controller

这篇关于什么是我的控制器在我的应用程序与MVVM设计模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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