DataGrid 中的对象不会触发它们所在的 BindingList 中的 ListChanged 事件

发布于 2024-12-02 08:16:33 字数 904 浏览 3 评论 0原文

我已经阅读了几乎所有有关 DataGrid、BindingListListChanged 的 Stackoverflow 问题,但仍然没有答案。

我有一个名为 Invoice : INotifyPropertyChanged 的对象,它有一个 BindingList; : INotifyPropertyChanged 由多个 InvoiceLine : INotifyPropertyChanged 对象组成。

现在,当在绑定到 BindableListDataGrid 中时,我将 InvoiceLine 的属性之一更改为 PropertyChanged< /code> 事件已触发,但 BindableList 上未触发 ListChanged 事件。

InvoiceLines 的初始化如下:

this.InvoiceLines = new BindingList<InvoiceLine>();
this.InvoiceLines.ListChanged += new System.ComponentModel.ListChangedEventHandler(InvoiceLines_ListChanged);
this.InvoiceLines.RaiseListChangedEvents = true;
this.InvoiceLines.AllowEdit = true;

I have read pretty much all Stackoverflow questions about DataGrid, BindingList<T> and ListChanged and still have no answer.

I have an object called Invoice : INotifyPropertyChanged, that has a BindingList<InvoiceLine> : INotifyPropertyChanged that consists of number of InvoiceLine : INotifyPropertyChanged objects.

Now when in the DataGrid that is bound to the BindableList<InvoiceLine> I change one of the properties of a InvoiceLine a PropertyChanged event is fired but ListChanged event is not fired on the BindableList<InvoiceLine>.

InvoiceLines is initialized like this:

this.InvoiceLines = new BindingList<InvoiceLine>();
this.InvoiceLines.ListChanged += new System.ComponentModel.ListChangedEventHandler(InvoiceLines_ListChanged);
this.InvoiceLines.RaiseListChangedEvents = true;
this.InvoiceLines.AllowEdit = true;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文