通过绑定对象获取DataGrid Row

时间:2012-02-14 16:32:09

标签: c# .net wpf binding datagrid

我有一个绑定到DataGrid的List<T>集合。 T是一些带有一些公共属性的类,都定义了PropertyChangedEventHandler,以便正确更新网格,一切都很好。唯一的问题是我不知道如何引用我的集合条目绑定到的行。

例如:

List<T> collection = new List<T>();

// List has been filled with <T> objects

如何确定哪个DataGrid行(或单元格),collection [23]对象绑定到哪个?如何返回对此行的引用?

非常感谢你的帮助!!!

1 个答案:

答案 0 :(得分:0)

我使用了我的DataGrid实例的ItemContainerGenerator.ContainerFromItem(binded_object)方法,正如Rachel建议的那样,得到了实际的DataGridRow引用,这正是我所需要的。

相关问题