0
我想要做的是从内容中获取行索引。获取DataGrid行索引的值?
我有2列,一个用于Identifier
(如DataGridTextColumn)和另一个用于Refferer
引用特定标识符的数据网格(如DataGridTemplateColumn标签,它具有mouseUp处理和条件格式)。
我也有一个CollectionViewSource
与源作为列表,其中包含标识符和引用。
当点击来自引荐列的项目时,mouseUp处理检索标签的内容,就像这样:
private void Item_MouseUp(object sender, RoutedEventArgs e) {
string _Referrer = (string)(sender as Label).Content;
//Something here to get index of row that contains _Referrer.
e.Handled = true;
}
我试图命名我的DataGrid和做`dataGrid.Items.IndexOf(_Referrer )但这不会产生该项目的索引。
我检索该行指数的意图是,这样我可以有利用滚动到具体项目的列表:
dataGrid.SelectedIndex = IndexOfIdentifier;
dataGrid.UpdateLayout();
dataGrid.ScrollIntoView(dataGrid.SelectedItem);
什么类的名称中包含标识符和单个项目遭受冲击? – VMaleev
就像'class People {public string ID {get;组; }公共字符串Referrer {get;组; }}' – Sakuya
您的Referrer属性对于每个人的实例都是唯一的吗? – VMaleev