WPF DataGrid CellEditEnded event

前端 未结 3 1802
北海茫月
北海茫月 2021-01-19 00:11

I\'m looking to know every time the user has edited a content of my DataGrid\'s cell. There\'s CellEditEnding event, but its called before any changes were made to the colle

3条回答
  •  伪装坚强ぢ
    2021-01-19 00:48

    You should just add an event handler on your ObservableCollection's CollectionChanged event.

    Code snippet:

    _listObsComponents.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(ListCollectionChanged);
    
    // ...
    
    
        void ListCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            /// Work on e.Action here (can be Add, Move, Replace...)
        }
    

    when e.Action is Replace, this means that an object of your list has been replaced. This event is of course triggered after the changes were applied

    Have fun!

提交回复
热议问题