/// <summary> /// 查找DataGrid某个单元格中的控件 /// </summary> /// <param name="myDataGrid">DataGrid名称</param> /// <param name="columnIndex"></param> /// <param name="rowIndex"></param> /// <param name="controlName">要查找的控件名称</param> /// <returns></returns> public object FindName(System.Windows.Controls.DataGrid myDataGrid, int columnIndex, int rowIndex, string controlName) { FrameworkElement item = myDataGrid.Columns[columnIndex].GetCellContent(myDataGrid.Items[rowIndex]); DataGridTemplateColumn temp = (myDataGrid.Columns[columnIndex] as DataGridTemplateColumn); return temp.CellTemplate.FindName(controlName, item); }