private void btnAddGrouping_Click(object sender, RoutedEventArgs e) { ICollectionView view = CollectionViewSource.GetDefaultView(MyDataGrid.ItemsSource); if (view == null) { return; } if (view.GroupDescriptions.Count == 0) { view.GroupDescriptions.Add(new PropertyGroupDescription("Department")); } else if (view.GroupDescriptions.Count == 1) { view.GroupDescriptions.Add(new PropertyGroupDescription("Gender")); } if (MyDataGrid.GroupStyle == null || MyDataGrid.GroupStyle.Count == 0) { GroupStyle groupStyle = TryFindResource("GroupHeaderStyle") as GroupStyle; MyDataGrid.GroupStyle.Add(groupStyle); } MyDataGrid.UpdateLayout(); ScrollToSelection(); MyDataGrid.Focus(); }
public void FindNextWordCommandExecute() { currentIndex++; currentIndex %= ResultList.Count; SelectedResult = ResultList.ElementAt(currentIndex); MyDataGrid.UpdateLayout(); MyDataGrid.ScrollIntoView(MyDataGrid.SelectedItem); }
public void FindPreviousWordCommandExecute() { currentIndex--; if (currentIndex < 0) { currentIndex = ResultList.Count - 1; } SelectedResult = ResultList.ElementAt(currentIndex); MyDataGrid.UpdateLayout(); MyDataGrid.ScrollIntoView(MyDataGrid.SelectedItem); }