MVVM 中的 IEditableObject [英] IEditableObject in MVVM
问题描述
您能想出一个场景,其中 IEditableObject
在基于 MVVM 的 WPF 应用程序中仍然有用吗?如果是这样,您是否有一个示例可以证明这一点.
Can you think of a scenario where IEditableObject
would be still usefull in an MVVM-based WPF application? If so, do you have an example that demonstrates this.
推荐答案
我在我的一个应用程序中使用了 IEditableObject
.例如,如果您有一个用于编辑内容的对话框,则可以在 ViewModel 上实现 IEditableObject.当对话框打开时调用 BeginEdit()
,当用户单击 OK 时调用 EndEdit()
,当用户单击取消时调用 CancelEdit()
.
I have used IEditableObject
in one of my applications. For example if you have a dialog for editing something, you could implement IEditableObject on your ViewModel. You call BeginEdit()
when the dialog opens, EndEdit()
when the user clicks OK, and CancelEdit()
when the user clicks cancel.
IEditableObject
是一个很好的界面,您可以随时回滚更改.
IEditableObject
is a good interface anytime you want to be able to roll back changes.
这篇关于MVVM 中的 IEditableObject的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!