wpf - 为什么两个模型不应该互相交谈

标签 wpf silverlight mvvm prism

Well , In MVVM pattern it is good practice that two models should not know or talk with each other. That means you should not create a object of one model in other and then register for event or performing similar things.

But why, what is wrong if two models know each other. I am writing the code and what will happen if both my models know each other.

最佳答案

View 模型之间相互操作通常非常合适。毕竟, View 中的父/子关系涉及包含 subview 模型集合的父 View 模型。在许多情况下,例如,父 View 中命令的可用性取决于其子状态。有时将其委派给一个单独的 Controller 类是适当的,但是这样做通常也不值得。

这实际上取决于应用程序的整体复杂性。有时,这种努力是必不可少的。有时只是镀金。

关于wpf - 为什么两个模型不应该互相交谈,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4095348/

相关文章:

c# - 我可以使用wpf鼠标事件替换触摸事件吗?

c# - 使用Silverlight隔离存储来保存身份验证 token ?

c# - Telerik RadListBox - 如何默认选择某些项目?

c# - 如何从列表控件向 ViewModel ObservableCollection 属性添加项目? WPF MVVM

c# - 如何在 WPF DataGrid 的列标题中设置垂直文本?

C#:创建图形屏幕保护程序

C# ComboBox 项目不显示

c# - 扩展方法的问题

c# - 如何在不丢失 WPF 中的绑定(bind)的情况下更改 TextBox.Text?

WPF//MahApps.Metro//Caliburn.Micro//Flyout//HeaderedContentControl