在我的系统中,我需要捕获并发送单元格编辑的旧值和新值。我读过,你可以通过这样的检查事件DataGridCellEditEndingEventArgs的EditingElement做到这一点:WPF DataGrid - 编辑结束后单元格的新值
_dataGrid.CellEditEnding += (sender, e) => {
var editedTextbox = e.EditingElement as TextBox;
if (editedTextbox != null)
MessageBox.Show("Value after edit: " + editedTextbox.Text);
}
在我的情况下,该数据是一本字典,因此EditingElement是ContentPresenter
var editedTextbox = e.EditingElement as ContentPresenter;
if (editedTextbox != null)
MessageBox.Show("Value after edit: " + editedTextbox.Content);
和内容是原始的,而不是新的编辑值。
我怎样才能得到这个工作:
_dataGrid.SomeEvent(sender, e)->{
SendValues(e.oldCellValue, e.newCellValue);
}
也请在这里看看http://stackoverflow.com/questions/18720892/wpf-datagrid-columns-how-to-manage-event-of-value -changing – Gilad 2015-01-26 20:03:21
除非我错过了一些东西,我不认为这有帮助 - 我已经改变了数据网格选择,并且工作正常。我现在需要在编辑它之前和之后观察单元格的数据值 - 希望这两个数据片段可以在其中一个回调函数中使用。 – jchristof 2015-01-27 14:30:34
这工作对我来说,看看http://stackoverflow.com/questions/3938040 – 2015-06-23 12:32:39