0

我有一个用户控件,其中一个 DataGrid 绑定到一个 observablecollection 项目和两个按钮:保存更改和放弃更改。

我的问题是,当用户编辑 datagridrow 时,按钮保持可点击但未执行。

有没有办法在 DataGrid 处于编辑模式时禁用按钮?

我试过这段代码没有成功:

<Button Content="SaveChanges" Command="{Binding Path=CmdSaveChanges}" 
                IsEnabled="{Binding ElementName=MyDataGrid, Path=IsEditing, Converter={StaticResource InverseBooleanConverter}}" />
4

1 回答 1

1

您正在绑定到名为DataGridIsEditing的元素的属性。MyDataGrid但是,DataGrid 没有这样的属性。

尽管DataGridCell具有IsEditing属性,但没有简单的方法可以获取当前正在编辑的单元格。DataGrid.CurrentCell不会给你 DataGridCell,而只会给你一个DataGridCellInfo

将处理程序附加到 DataGrid 的BeginningEditCellEditEnding事件可能会更好。

于 2012-05-09T10:55:47.533 回答