Example #1
0
        private void PerformCustomSort(DataGridColumn column)
        {
            Field         field         = (Field)column.GetValue(DataGridExtensions.FieldProperty);
            SortDirection sortDirection = column.SortDirection == ListSortDirection.Ascending ? SortDirection.Ascending : SortDirection.Descending;

            if ((Keyboard.Modifiers & ModifierKeys.Shift) == 0)
            {
                CdListSort.Clear();
            }

            SortField sortFieldFound = CdListSort.FirstOrDefault(x => x.Field == field);

            if (sortFieldFound != null)
            {
                sortFieldFound.SortDirection = sortDirection;
            }
            else
            {
                CdListSort.Add(new SortField(field, sortDirection));
            }
            ListSortDirection direction = (column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending;

            column.SortDirection = direction;
            ListCollectionView lcv    = (ListCollectionView)CollectionViewSource.GetDefaultView(dataGrid.ItemsSource);
            MySort             mySort = new MySort(DataBase, dataGrid, this.cdListFields, CdListSort);

            lcv.CustomSort = mySort;    // provide our own sort
        }
Example #2
0
        void bwCDList_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            SafeObservableCollection <AlbumItem> items = e.Result as SafeObservableCollection <AlbumItem>;

            ListCollectionView lcv = new ListCollectionView(items);

            lcv.Filter = FilterRow;

            if (GroupBy != null && GroupBy.Count > 0)
            {
            }

            dataGrid.ItemsSource = lcv;

            LoadSorting();

            MySort mySort = new MySort(DataBase, dataGrid, this.cdListFields, this.CdListSort);

            lcv.CustomSort = mySort;    // provide our own sort

            if (dataGrid.Items.Count > 0)
            {
                dataGrid.UpdateLayout();
                dataGrid.ScrollIntoView(dataGrid.Items[0]);
            }

            if (FillListCompleted != null)
            {
                FillListCompleted(this, new EventArgs());
            }

            SaveDataGridColumnWidths();


            //UpdateStatusBar();
        }