static void RegenerateRows( ErrorsListView listView, List <ErrorMessage> errorMessages, TreeViewItem rootItem, List <TreeViewItem> rows) { ClearRows(rootItem, rows); if (errorMessages.Count == 0) { return; } for (int i = 0; i < errorMessages.Count; i++) { ErrorListViewItem errorListViewItem = new ErrorListViewItem(i + 1, errorMessages[i]); rootItem.AddChild(errorListViewItem); rows.Add(errorListViewItem); } listView.SetSelection(new List <int> { 1 }); }
static List <ErrorMessage> GetSelectedErrors( ErrorsListView listView) { List <ErrorMessage> result = new List <ErrorMessage>(); IList <int> selectedIds = listView.GetSelection(); if (selectedIds.Count == 0) { return(result); } foreach (ErrorListViewItem treeViewItem in listView.FindRows(selectedIds)) { result.Add(treeViewItem.ErrorMessage); } return(result); }