
我希望单击此数据网格的末尾行(在上图中)。单击此选项时,我希望能够找到被单击的行,并将行号传递给另一个表单。
下面是我尝试过的几个尝试:
private void CellClicked(object sender, MouseButtonEventArgs e)
{
int cell = dgFake.Items.IndexOf(((DataRowView)dgFake.Items[5]).Row);
xamlAllocteAudits window = new xamlAllocteAudits
{
DataContext = cell
};
window.Show();无论我在列中的哪个位置单击,此尝试都会保留为值'-1‘。
private void CellClicked(object sender, MouseButtonEventArgs e)
{
int cell = dgFake.Items.IndexOf(dgFake.SelectedIndex);
xamlAllocteAudits window = new xamlAllocteAudits
{
DataContext = cell
};
window.Show();这次尝试显示了一个从'-1‘开始的不同的数字,每次我单击列中的单元格时都会递增,但即使我单击底部的单元格,第一次单击也始终是'-1',因此我假设这不是行号的值。
发布于 2013-11-20 21:12:21
类似的问题也被回答了,here看看。
https://stackoverflow.com/questions/20096700
复制相似问题