C# 如何在WPF中访问DataGrid的备用代码

C# 如何在WPF中访问DataGrid的备用代码,c#,wpf,wpfdatagrid,C#,Wpf,Wpfdatagrid,我已经试过这个代码,但在WPF中没有得到答案。如何在WPF的DataGrid中对此进行编码 private void Change(string id, int current) { dataGridView.Rows[this.GetRowIndex(id)].Cells[8].Value = (object) current; } private int GetRowIndex(string ID) { int num = -1; foreach (DataGridViewR

我已经试过这个代码,但在WPF中没有得到答案。如何在WPF的DataGrid中对此进行编码

private void Change(string id, int current)
 {
 dataGridView.Rows[this.GetRowIndex(id)].Cells[8].Value = (object) current;
 }

private int GetRowIndex(string ID)
{
  int num = -1;
  foreach (DataGridViewRow dataGridViewRow in (IEnumerable) this.dataGridView.Rows)
  {
    if (dataGridViewRow.Cells[0].Value.Equals((object) ID))
      num = dataGridViewRow.Index;
  }
  return num;
}

WPF datagridd的替代代码是什么?

最好在源代码中进行更改。从这个问题上看,还不清楚您想要实现什么。与其发布一些代码并要求他人为您翻译,不如描述您试图实现的行为。