private void SearchPaintListDataGrid(string str) { bool f = false; object findObj = null; foreach (var obj in viewSource.View) { // 選択行まで進める if (obj == viewSource.View.CurrentItem) { f = true; continue; } // 検索する if (f && ViewModel.FindStringIsContains(obj, str)) { findObj = obj; break; } } // 最後まで該当無ければ先頭から検索する if (findObj == null) { foreach (var obj in viewSource.View) { // 検索する if (ViewModel.FindStringIsContains(obj, str)) { findObj = obj; break; } // 選択行まで進んだら終了 if (obj == viewSource.View.CurrentItem) { break; } } } if (findObj != null) { viewSource.View.MoveCurrentTo(findObj); } else { // todo: ステータスバーに表示 System.Diagnostics.Debug.WriteLine("検索結果無し"); } // スクロール PaintListDataGrid.ScrollIntoView(viewSource.View.CurrentItem); }
// 基準カラー設定 private void SelectFindPaint(object sender, RoutedEventArgs e) { // VM にイベント送信 基準カラー設定 ΔE 計算 ViewModel.FindPaintChange(); // DataGrid ΔE 列でソート viewSource.SortDescriptions.Clear(); viewSource.SortDescriptions.Add(new SortDescription() { PropertyName = "DeltaE", Direction = ListSortDirection.Ascending }); viewSource.View.Filter = ViewModel.SeriesListIsSelected; // ColorCode_DataGridTextColumn.SortDirection = null; ColorName_DataGridTextColumn.SortDirection = null; Note_DataGridTextColumn.SortDirection = null; DeltaE_DataGridTextColumn.SortDirection = ListSortDirection.Ascending; // DataGrid 先頭行にスクロール PaintListDataGrid.ScrollIntoView(viewSource.View.CurrentItem); }