WPF - ObservableCollection PropertyChanged 事件?
我有一个对象,它具有 ObservableCollection
类型的属性。它使用 TwoWay 绑定绑定到表单上的复选框列表。我想为此添加一个 PropertyChanged 通知,以便在选择某些值时,其他一些值会自动取消选择。有办法做到这一点吗?
当集合中的值发生更改并且我使用 MVVM 设计模式时,不会触发 ObservableCollection.PropertyChanged 事件。
I have an object which has a property of type ObservableCollection<bool>
. It is bound to a list of checkboxes on a form using TwoWay bindings. I would like to add a PropertyChanged notification to this so that if certain values are selected, some other ones get automatically deselected. Is there a way to do this?
The ObservableCollection.PropertyChanged event doesn't get triggered when a value in the collection gets changed and I'm using the MVVM design pattern.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要使用自己的类来实现 INotifyPropertyChanged 接口。您将无法使用 bool,但您可以在类中拥有一个您想要的 bool 属性。
You would need to use your own class that implements the INotifyPropertyChanged interface. You won't be able to use bool, but you can have a single property in your class that is that bool that you want.