Exemple #1
0
        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();
        }
Exemple #2
0
        private void btnClearGrouping_Click(object sender, RoutedEventArgs e)
        {
            ICollectionView view = CollectionViewSource.GetDefaultView(MyDataGrid.ItemsSource);

            if (view == null)
            {
                return;
            }

            if (view.GroupDescriptions.Count == 2)
            {
                view.GroupDescriptions.RemoveAt(1);
            }
            else if (view.GroupDescriptions.Count == 1)
            {
                view.GroupDescriptions.RemoveAt(0);
            }

            ScrollToSelection();
            MyDataGrid.Focus();
        }
Exemple #3
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     loadGridData();
     MyDataGrid.Focus();
 }