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

前端 未结 7 610
失恋的感觉
失恋的感觉 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(), you must write strogly MyClass (not ObservableCollection())

提交回复
热议问题