我不想听INofifyPropertyChanged的Observable Collection [英] Observable Collection that I Don't want to listen to INofifyPropertyChanged

查看:88
本文介绍了我不想听INofifyPropertyChanged的Observable Collection的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我猜这是一个奇怪的问题/要求,但是有什么办法可以建立一个可观察的集合(或者使用其他类型的集合),而不监听INotifyPropertyChanged事件?我有一个列表框(主菜单),然后有一个详细信息部分(详细信息). 选择主行时,它将填充详细信息部分.如果更改单个字段之一,则会更改列表中的某个字段,因为我实现了INPC.在单击保存"按钮之前,我不希望更改反映出来.

I guess this is an odd question/request but is there any way to have an observable collection (or maybe use another type of collection) that doesn't listen to INotifyPropertyChanged events? I have a list box (master) and then a details section (detail). When selecting the Master row it populates the details section. If I change one of the individual fields it changes it in the list because I implement INPC. I don't want the change reflected until the Save button is clicked.

谢谢

推荐答案

查看 Binding.UpdateSourceTrigger 属性,可以使用它指定何时要更新绑定源.如文档所述,如果您将 将 UpdateSourceTrigger 值设置为 Explicit ,则必须调用

Check out the Binding.UpdateSourceTrigger property, you can use it to specify when you want the binding's source to be updated. As the documentation states, "If you set the UpdateSourceTrigger value to Explicit, you must call the UpdateSource method or the changes will not propagate back to the source."

因此,当您准备好保存"时,可以在保存按钮的单击事件处理程序中获取绑定表达式并在其上调用UpdateSource.变化.

Thus, in your save button's click event handler you can get the binding expression and call UpdateSource on it when you are ready to "save" the changes.

HTH


这篇关于我不想听INofifyPropertyChanged的Observable Collection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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