WPF DataGrid CellEditEnded event

前端 未结 3 1825
北海茫月
北海茫月 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:40

    You can use UpdateSourceTrigger=PropertyChangedon the binding of the property member for the datagrid. This will ensure that when CellEditEnding is fired the update has already been reflected in the observable collection.

    See below

    
              
                  
                      // Mvvm light relay command
                   
              
              
                         // Name is property on the object i.e Items.Name
              
    
    
    

    UpdateSourceTrigger = PropertyChanged will change the property source immediately whenever the target property changes.

    This will allow you to capture edits to items as adding an event handler to the observable collection changed event does not fire for edits of objects in the collection.

提交回复
热议问题