Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ';数据网格&x27;不包含';选择Drows';没有扩展方法_C#_Wpf_Datagrid - Fatal编程技术网

C# ';数据网格&x27;不包含';选择Drows';没有扩展方法

C# ';数据网格&x27;不包含';选择Drows';没有扩展方法,c#,wpf,datagrid,C#,Wpf,Datagrid,我试图在datagrind上单击特定行后获取该行。我制定了以下代码: private void dataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { string firstCellValue = dataGrid1.SelectedRows[0].Cells[0].Value; } 但我得到了这个错误: “DataGrid”不包含“SelectedRow”和“no”的定义 扩展方法“Se

我试图在datagrind上单击特定行后获取该行。我制定了以下代码:

private void dataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
    string firstCellValue = dataGrid1.SelectedRows[0].Cells[0].Value;    
}
但我得到了这个错误:

“DataGrid”不包含“SelectedRow”和“no”的定义 扩展方法“SelectdRows”接受类型为的第一个参数 找不到“DataGrid”(您是否缺少using指令或 汇编参考?)

我正在使用:

using System.Windows;
using System.Windows.Controls;
using System.Windows.Forms;

提前谢谢

看起来此控件对调用的控件具有不同的属性,而您似乎正在查找该属性

似乎您想要获得第一个选定行的第一个单元格,这应该适用于您的案例

string firstCellValue = dataGrid1.SelectedCells[0].Item.ToString();

您还需要添加PresentationFramework.dll。

dataGrid1是DataGrid。(来自System.Windows.Controls.DataGrid)@Tal很乐意帮忙。如果你发现一个答案很有用,别忘了写或/这样将来的读者会从中受益。我试过了,但我还没有15个名声(@down)我想评论一下,至少这样我可以看出我错在哪里?