検索クエリに基づいてDataGridの行をハイライト表示する簡単な検索機能を実装しました。これの要点を以下に示す:ソートされたDataGridの検索
public bool scrollToSearch(string query) {
dataGrid.SelectedItems.Clear();
for (; searchIndex < registrants.Count; searchIndex++) {
foreach (string field in registrants[searchIndex]) {
if (field.ToLower().Contains(query)) {
dataGrid.SelectedItem = registrants[searchIndex];
dataGrid.ScrollIntoView(registrants[searchIndex]);
searchIndex++;
return true;
}
}
}
}
それが一致するリストを検索し、その行ビューにスクロールして(選択)を強調しています。問題は、DataGridをソートすると、最初の結果ではなく一見ランダムな行が強調表示されることです。ソートされていない元のリストを検索しているからです。ソートされたリストで検索する方法がありますか?
[this](http://stackoverflow.com/questions/8896422/persist-sorting-from-datagrid-to-itemssource-collection)を参照してください。 –