Does WPF DataGrid fire an event when a row is added / removed?

前端 未结 7 620
失恋的感觉
失恋的感觉 2021-02-06 05:48

I wish to recalculate things everytime a DataGrid gets more rows or some are removed. I tried to use the Loaded event, but that was fired only once.

I found

相关标签:
7条回答
  • 2021-02-06 06:49

    If you want use ObservableCollection and get notification about add or another operation, the best way use INotifyCollectionChanged

    var source = datagrid.ItemsSource as INotifyCollectionChanged;
    

    Because, when you will unwrap to ObservableCollection<MyClass>(), you must write strogly MyClass (not ObservableCollection<ParentOfMyClass>())

    0 讨论(0)
提交回复
热议问题