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/