【发布时间】:2011-06-08 03:00:53
【问题描述】:
我想在用户在数据网格中输入一行后立即验证用户输入的内容。
我应该查看什么事件,以及如何检索行数据?或者更好的是,它绑定到的对象?
【问题讨论】:
标签: c# wpf wpf-controls wpfdatagrid
我想在用户在数据网格中输入一行后立即验证用户输入的内容。
我应该查看什么事件,以及如何检索行数据?或者更好的是,它绑定到的对象?
【问题讨论】:
标签: c# wpf wpf-controls wpfdatagrid
如果您遇到问题,我已成功使用:
DataGridCellInfo selected = YourDataGrid.SelectedCells[0];
YourObject selectedRow = selected.Item as YourObject;
【讨论】:
使用RowEditEnding 事件。
private void DataGrid_RowEditEnding(object sender, DataGridRowEditEndingEventArgs e)
{
YourObject obj = e.Row.Item as YourObject;
if (obj != null)
{
//see obj properties
}
}
【讨论】:
e 上的Row 属性,但我仍然不确定如何检索输入的数据?
DataGridRowEditEndingEventArgs,它有行数据对象。如果您看到奇怪的行为,请详细说明。 (见我的编辑)
e.Row.Item 是存储数据的地方...这就是我想知道的!
【讨论】: