如何解决如何了解CurrentCell在WPF DataGrid中是否处于编辑模式?
我正在创建自定义DataGrid
。当我按下键盘时,我想了解CurrentCell
是否处于编辑模式。我知道如何处理KeyDown
事件。我发现了this和this的帖子。那里的解决方案没有帮助解决我的问题。我找不到找出CurrentCell
是否处于编辑模式的更好方法。我怎样才能做到这一点?有什么解决办法吗?
解决方法
您可以处理BeginningEdit
和CellEditEnding
并使用一个变量来跟踪当前编辑的单元格:
private DataGridCellInfo _editedCell;
private void DataGrid_BeginningEdit(object sender,DataGridBeginningEditEventArgs e)
{
_editedCell = dataGrid.CurrentCell;
}
private void DataGrid_CellEditEnding(object sender,DataGridCellEditEndingEventArgs e)
{
_editedCell = default(DataGridCellInfo);
}
然后您可以使用该变量检查单元格当前是否处于编辑模式:
if (dataGrid.CurrentCell == _editedCell)
...
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。