WPF ObservableCollection 编辑模式 [英] WPF ObservableCollection Edit Mode

查看:21
本文介绍了WPF ObservableCollection 编辑模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中使用了可观察的集合.我的问题是,当我使用弹出窗口编辑这些实体时,当用户更改窗口中的相应字段时,我的绑定列表也会更改.

I am using observable collections all around my applications. My problem is that when i use a popup window for editing those entities, my bound lists are getting changed when the user changes those corresponding fields in the window.

如何简单地冻结可观察到的更改规范,并仅在实体被保存时释放它们?

How could i simply freeze the observable changes norifications, and release them only when the entity is saved?

谢谢,奥兰

推荐答案

你可以制作一个 您要编辑的对象的深层副本.这样,您可以在编辑时对副本进行操作,而不会干扰保留在列表中的原件.编辑完成后,您可以用编辑后的版本替换原始版本或回滚.

You could make a deep copy of the object you want to edit. This way, you can act on the copy while editing, without interfering with the original that remains in the list. Once you`re done editing, you can replace the original by the edited version or rollback.

这篇关于WPF ObservableCollection 编辑模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆