There is a class derived from DataGrid MWF. It is programmatically necessary to select the line (one) by criterion. Code:
//for (var i=0; i<_newList.Count;i++) //{ // var am = _newList[i]; // if (am.id == _SelId) // { // //DataGridRow row = AlarmMessagesDataGrid.ItemContainerGenerator.ContainerFromIndex(i) as DataGridRow; // AlarmMessagesDataGrid.SelectedIndex = i; // break; // } //} foreach (AlarmMessage am in AlarmMessagesDataGrid.Items) { if (am.id == _SelId) { AlarmMessagesDataGrid.SelectedIndex = AlarmMessagesDataGrid.Items.IndexOf(am); break; } } AlarmMessagesDataGrid is a class AlarmMessagesDataGrid from DataGrid (with the ability to filter by columns). _SelId - the criterion that this line should be selected.
How many did not fight - the code does not work. There are no mistakes. In the code the debugging is normal. "Manual" (by clicking the row of the table) selection works.
I do not know what to do anymore (One of the code variants is commented out)
AlarmMessagesDataGrid.Items.IndexOf(am);what number returns? - tym32167