gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 10:20:41 26 4
gpt4 key购买 nike

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com