编辑:接受 Chris Holmes 的回复,但如果有人想出更好的方法,随时准备重构!谢谢!
用 MVP 做一些 winforms 什么是将实体传递到另一个视图的最佳方式。
假设我有一个CustomerSearchView/Presenter
,在 doubleClick 上我想显示CustomerEditView/Presenter
. 我不想让我的视图知道模型,所以我不能创建一个带有ICustomer
in 参数的 ctor。
我的反应是,
CustomerSearchView
创建一个新的CustomerEditView
,它创建它自己的演示者。然后我CustomerSearchView
会做类似的事情:
var customerEditView = new CustomerEditView();
customerEditView.Presenter.Customer = this.Presenter.SelectedCustomer;
其他可能的方法是一个CustomerDTO
类,并让一个CustomerEditView
接受其中的一个CustomerDTO
,但我认为这是很多简单的工作。
对不起,基本问题,但我能找到的所有例子都没有达到这一点,这是一个棕地项目,到目前为止使用的方法让我头疼......