WPF DataGrid CellEditEnded event

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

    If you need to know whether the edited DataGrid item belongs to a particular collection, you could do something like this in the DataGrid's RowEditEnding event:

        private void dg_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
        {
            // dg is the DataGrid in the view
            object o = dg.ItemContainerGenerator.ItemFromContainer(e.Row);
    
            // myColl is the observable collection
            if (myColl.Contains(o)) { /* item in the collection was updated! */  }
        }
    

提交回复
热议问题