private void dataGrid1_Sorting(object sender, DataGridSortingEventArgs e) { sortMemberPath = e.Column.SortMemberPath; sortDirection = e.Column.SortDirection != ListSortDirection.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending; }
private void tracklist_Sorting(object sender, System.Windows.Controls.DataGridSortingEventArgs e) { switch (e.Column.Header.ToString()) { case "Songs": EnumerationsContainer.LibraryTrackFilter = TrackFilter.Songs; break; case "Artist": EnumerationsContainer.LibraryTrackFilter = TrackFilter.Artist; break; case "Album": EnumerationsContainer.LibraryTrackFilter = TrackFilter.Album; break; case "Genre": EnumerationsContainer.LibraryTrackFilter = TrackFilter.Genre; break; case "Bitrate": EnumerationsContainer.LibraryTrackFilter = TrackFilter.Bitrate; break; case "": EnumerationsContainer.LibraryTrackFilter = TrackFilter.Rate; break; } e.Handled = true; if (CurrentSearchPackage != null) { TrackQuery.FindTracks(CurrentSearchPackage, Dispatcher); } else { var mySearchType = SearchType.trYear; if (Settings.Default.SearchSongs) { mySearchType |= SearchType.trTitle; } if (Settings.Default.SearchArtists) { mySearchType |= SearchType.trArtist; } if (Settings.Default.SearchAlbums) { mySearchType |= SearchType.trAlbum; } if (Settings.Default.SearchGenres) { mySearchType |= SearchType.trGenre; } TrackQuery.FindTracks( new SearchPackage { Data = "", SearchType = mySearchType }, Dispatcher); } }
private void DataGrid_Sorting(object sender, DataGridSortingEventArgs e) { VM.SortByDesc = !VM.SortByDesc; if (!string.IsNullOrEmpty(e.Column.SortMemberPath)) { VM.SortedBy = e.Column.SortMemberPath; VM.Refresh(); } }
protected override void OnSorting(DataGridSortingEventArgs eventArgs) { var column = eventArgs.Column; var direction = (column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; column.SortDirection = direction; var lcv = (ListCollectionView)CollectionViewSource.GetDefaultView(ItemsSource); var mySort = new MySort(direction, column); lcv.CustomSort = mySort; }
private void OnSorting(object sender, DataGridSortingEventArgs eventArgs) { eventArgs.Handled = true; if (SortCommand != null) { var column = eventArgs.Column; var sortDirection = GetNextSortDirection(column.SortDirection); column.SortDirection = sortDirection; SortCommand.Execute(new SortData(column.Header.ToString(), sortDirection)); } }
private void RootTreeGrid_Sorting(object sender, DataGridSortingEventArgs e) { // SortDirection if (SortDirection == ListSortDirection.Ascending) { SortDirection = ListSortDirection.Descending; } else { SortDirection = ListSortDirection.Ascending; } _rootNode.Sort(); e.Handled = true; }
private static void DataGridOnSorting(object sender, DataGridSortingEventArgs e) { var dataGrid = (DataGrid)sender; var data = GetDataSource(dataGrid); var ascending = e.Column.SortDirection == ListSortDirection.Ascending; var direction = ascending ? ListSortDirection.Descending : ListSortDirection.Ascending; data.Sort(e.Column.DisplayIndex, ascending); e.Column.SortDirection = direction; e.Handled = true; }
private static void DataGridSorting(object sender, DataGridSortingEventArgs args) { DataGridColumn column = args.Column; if (column.SortDirection == null) column.SortDirection = ListSortDirection.Ascending; else if (column.SortDirection == ListSortDirection.Ascending) column.SortDirection = ListSortDirection.Descending; else column.SortDirection = null; args.Handled = true; }
private void RootTreeGrid_Sorting(object sender, DataGridSortingEventArgs e) { SortDirection = ListSortDirection.Ascending; if (e.Column.SortDirection.HasValue) { if (e.Column.SortDirection.Value == ListSortDirection.Ascending) { SortDirection = ListSortDirection.Descending; // toggle } } e.Column.SortDirection = SortDirection; _rootNode.Sort(); e.Handled = true; }
private void DataGrid_Sorting(object sender, DataGridSortingEventArgs e) { if (e.Column.SortMemberPath != m_sortMemberPath) m_sortDirection = ListSortDirection.Ascending; else if (m_sortDirection == ListSortDirection.Ascending) m_sortDirection = ListSortDirection.Descending; else m_sortDirection = ListSortDirection.Ascending; m_sortColumn = e.Column; m_sortMemberPath = e.Column.SortMemberPath; m_dataContext.SortData(m_sortMemberPath, m_sortDirection); }
private void RealtorsGrid_Sorting(object sender, DataGridSortingEventArgs e) { e.Handled = true; ListSortDirection direction = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; e.Column.SortDirection = direction; ListCollectionView lcv = (ListCollectionView) CollectionViewSource.GetDefaultView(dataGrid.ItemsSource); SortLogic sortLogic = new SortLogic(direction, e.Column); lcv.CustomSort = sortLogic; }
/// <summary> /// Sortuje dane i przechodzi do pierwszej strony /// </summary> /// <param name="e"></param> public void Sort(DataGridSortingEventArgs e) { // has to be done manually, SortDirection is set to null every time ItemsSource changes if (SortDirection == ListSortDirection.Descending || e.Column.SortMemberPath != SortProperty) { SortDirection = ListSortDirection.Ascending; } else { SortDirection = ListSortDirection.Descending; } SortProperty = e.Column.SortMemberPath; CurrentPage = 1; e.Handled = true; UpdateData(); }
protected override void OnSorting(DataGridSortingEventArgs eventArgs) { eventArgs.Handled = true; var src = this.ItemsSource as RawDataItemsSource; var col = eventArgs.Column as IRawDataColumn; if (src == null || col == null) return; var nextDir = (eventArgs.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; eventArgs.Column.SortDirection = nextDir; var cmp = col.GetComparer(nextDir); src.Comparer = cmp; }
public void OnPartitionSorting(System.Windows.Controls.DataGridSortingEventArgs e) { if (e.Column.SortDirection == null) { e.Column.SortDirection = ListSortDirection.Ascending; } if (PartitionSortColumn == e.Column.SortMemberPath) { PartitionSortDirection = PartitionSortDirection * -1; } else { PartitionSortDirection = -1; } PartitionSortColumn = e.Column.SortMemberPath; }
public void OnRelationshipSorting(System.Windows.Controls.DataGridSortingEventArgs e) { if (e.Column.SortDirection == null) { e.Column.SortDirection = ListSortDirection.Ascending; } if (RelationshipSortColumn == e.Column.SortMemberPath) { RelationshipSortDirection = RelationshipSortDirection * -1; } else { RelationshipSortDirection = -1; } RelationshipSortColumn = e.Column.SortMemberPath; }
private void DataGrid_Sorting(object sender, DataGridSortingEventArgs e) { if (!string.IsNullOrEmpty(e.Column.SortMemberPath)) { var context = (MarketplaceViewModel)DataContext; if (context.SortMemberPath == e.Column.SortMemberPath) { context.IsAscending = !context.IsAscending; } else { context.SortMemberPath = e.Column.SortMemberPath; context.IsAscending = true; e.Column.SortDirection = ListSortDirection.Ascending; } context.SearchCommand.Execute(); } e.Handled = true; }
void OnDataGridSorting(object sender, DataGridSortingEventArgs e) { var dataGrid = (DataGrid)sender; var column = e.Column; // prevent the built-in sort from sorting e.Handled = true; var direction = column.SortDirection != ListSortDirection.Ascending ? ListSortDirection.Ascending : ListSortDirection.Descending; //set the sort order on the column column.SortDirection = direction; //use a ListCollectionView to do the sort. var lcv = (ListCollectionView)CollectionViewSource.GetDefaultView(dataGrid.ItemsSource); //apply the sort lcv.CustomSort = new WindowsGroupPermissionComparer(direction, column.SortMemberPath); }
protected override void OnSorting(DataGridSortingEventArgs eventArgs) { string sortPropertyName = eventArgs.Column.SortMemberPath; if (!string.IsNullOrEmpty(sortPropertyName)) { var index = Items.SortDescriptions.Select(x => (SortDescription?)x).FirstOrDefault(x => x.Value.PropertyName == sortPropertyName); if (index != null) { Items.SortDescriptions.Remove(index.Value); } if (!eventArgs.Column.SortDirection.HasValue) { index = new SortDescription { PropertyName = sortPropertyName, Direction = ListSortDirection.Descending }; Items.SortDescriptions.Add(index.Value); } else if (eventArgs.Column.SortDirection.Value == ListSortDirection.Descending) { index = new SortDescription { PropertyName = sortPropertyName, Direction = ListSortDirection.Ascending }; Items.SortDescriptions.Add(index.Value); } foreach (var col in Columns) { var item = Items.SortDescriptions.Select(x=>(SortDescription?)x).FirstOrDefault(y => col.SortMemberPath == y.Value.PropertyName); if (item != null) { col.SortDirection = item.Value.Direction; } else { col.SortDirection = null; } } Items.Refresh(); eventArgs.Handled = true; } }
private void AvailablePackagesList_Sorting(object sender, DataGridSortingEventArgs e) { string sortPropertyName = e.Column.GetSortMemberPath(); if (!string.IsNullOrEmpty(sortPropertyName)) { bool sortDescending; if (!e.Column.SortDirection.HasValue || (e.Column.SortDirection.Value == ListSortDirection.Ascending)) { sortDescending = true; } else { sortDescending = false; } _vm.AvailablePackagesViewModel.SortDescending = sortDescending; _vm.AvailablePackagesViewModel.SortColumn = sortPropertyName; e.Handled = true; } }
private static void OnDataGridSorting(object sender, DataGridSortingEventArgs e) { var column = e.Column; var columnComparer = (ColumnComparer)column.GetValue(ColumnComparerProperty); var dataGrid = (DataGrid)sender; var view = CollectionViewSource.GetDefaultView(dataGrid.ItemsSource) as ListCollectionView; if (view == null) { return; } if (columnComparer == null) { view.CustomSort = (IComparer)dataGrid.GetValue(PreviousComparerProperty); } else { if (!(view.CustomSort is ColumnComparer)) { dataGrid.SetValue(PreviousComparerProperty, view.CustomSort); } switch (column.SortDirection) { case ListSortDirection.Ascending: column.SortDirection = ListSortDirection.Descending; view.CustomSort = columnComparer.Descending; break; case null: case ListSortDirection.Descending: column.SortDirection = ListSortDirection.Ascending; view.CustomSort = columnComparer.Ascending; break; default: throw new ArgumentOutOfRangeException(); } e.Handled = true; } }
// Deactivate the default Grid sorting, call the ISortbleSorting protected override void OnSorting(DataGridSortingEventArgs eventArgs) { eventArgs.Handled = true; _currentSortColumn = eventArgs.Column; var direction = (_currentSortColumn.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; // Call ISortable Sorting to sort the complete collection if (FullItemsSource != null) { FullItemsSource.Sort(_currentSortColumn.SortMemberPath, direction.ToString()); } _currentSortColumn.SortDirection = null; _currentSortColumn.SortDirection = direction; _currentSortDirection = direction; }
void FilteringDataGrid_Sorting(object sender, System.Windows.Controls.DataGridSortingEventArgs e) { var view = CollectionViewSource.GetDefaultView(Items); foreach (var column in Columns) { var sd = Helpers.FindSortDescription(view.SortDescriptions, column.SortMemberPath); if (sd.HasValue) { column.SortDirection = sd.Value.Direction; } } if (e.Column.SortDirection.HasValue) { view.SortDescriptions.Remove(view.SortDescriptions.FirstOrDefault(sd => sd.PropertyName == e.Column.Header.ToString())); switch (e.Column.SortDirection.Value) { case ListSortDirection.Ascending: e.Column.SortDirection = ListSortDirection.Descending; view.SortDescriptions.Add(new SortDescription(e.Column.Header.ToString(), ListSortDirection.Descending)); break; case ListSortDirection.Descending: e.Column.SortDirection = null; break; default: break; } } else { e.Column.SortDirection = ListSortDirection.Ascending; view.SortDescriptions.Add(new SortDescription(e.Column.Header.ToString(), ListSortDirection.Ascending)); } e.Handled = true;; }
private static void HandleCustomSorting(object sender, DataGridSortingEventArgs e) { var dataGrid = sender as DataGrid; if (dataGrid == null || !GetAllowCustomSort(dataGrid)) return; var listColView = dataGrid.ItemsSource as ListCollectionView; if (listColView == null) throw new Exception("The DataGrid's ItemsSource property must be of type, ListCollectionView"); // Sanity check var sorter = GetCustomSorter(e.Column); if (sorter == null) return; // The guts. e.Handled = true; var direction = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; e.Column.SortDirection = sorter.SortDirection = direction; listColView.CustomSort = sorter; }
private void DataGrid_Sorting(object sender, DataGridSortingEventArgs e) { m_dataContext.SortData(e.Column.SortMemberPath); }
/// <summary> /// Sort the issues based on the column clicked /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> /// <remarks>There's probably an easier way to do this but this works. Line number and line text are /// ignored as there's not much point in sorting on those values.</remarks> private void dgIssues_Sorting(object sender, DataGridSortingEventArgs e) { var issues = (IList<FileMisspelling>)dgIssues.ItemsSource; e.Handled = true; if(issues != null && issues.Count != 0) { IOrderedEnumerable<FileMisspelling> sort = null; var direction = (e.Column.SortDirection != ListSortDirection.Ascending) ? ListSortDirection.Ascending : ListSortDirection.Descending; switch(dgIssues.Columns.IndexOf(e.Column)) { case 0: if(direction == ListSortDirection.Ascending) sort = issues.OrderBy(i => i.ProjectName); else sort = issues.OrderByDescending(i => i.ProjectName); break; case 1: if(direction == ListSortDirection.Ascending) sort = issues.OrderBy(i => i.Filename); else sort = issues.OrderByDescending(i => i.Filename); break; case 3: if(direction == ListSortDirection.Ascending) sort = issues.OrderBy(i => i.IssueDescription); else sort = issues.OrderByDescending(i => i.IssueDescription); break; case 4: if(direction == ListSortDirection.Ascending) sort = issues.OrderBy(i => i.Word); else sort = issues.OrderByDescending(i => i.Word); break; default: break; } if(sort != null) { int idx = dgIssues.SelectedIndex; dgIssues.ItemsSource = new BindingList<FileMisspelling>(sort.ToList()); dgIssues.SelectedIndex = idx; e.Column.SortDirection = direction; dgIssues.Focus(); } } }
private void grdKeyList_Sorting(object sender, DataGridSortingEventArgs e) { VM.SortingByColumn(e.Column.SortMemberPath); e.Handled = true; }
private static void GridSorting(object sender, DataGridSortingEventArgs e) { var dataGrid = (DataGrid) sender; var sortPropertyName = GetSortMemberPath(e.Column); if (!string.IsNullOrEmpty(sortPropertyName)) { // sorting is cleared when the previous state is Descending if (e.Column.SortDirection.HasValue && e.Column.SortDirection.Value == ListSortDirection.Descending) { var index = FindSortDescription(dataGrid.Items.SortDescriptions, sortPropertyName); if (index != -1) { e.Column.SortDirection = null; // remove the sort description dataGrid.Items.SortDescriptions.RemoveAt(index); dataGrid.Items.Refresh(); if ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift) { // clear any other sort descriptions for the multisorting case dataGrid.Items.SortDescriptions.Clear(); dataGrid.Items.Refresh(); } // stop the default sort e.Handled = true; } } } }
private void ExportLogs_Sorting(object sender, DataGridSortingEventArgs e) { VM.LogSortByColum(e.Column.SortMemberPath); e.Handled = true; }
/// <summary> /// Handles the Sorting event of the StatColumn control. Uses a custom Sorting event handler that sorts a stat column in /// descending order, if it's not already sorted. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e"> /// The <see cref="DataGridSortingEventArgs" /> instance containing the event data. /// </param> private void statColumn_Sorting(object sender, DataGridSortingEventArgs e) { EventHandlers.StatColumn_Sorting((DataGrid) sender, e); }
/// <summary> /// Method to perform sorting on datagrid /// </summary> /// <param name="sortColumn"></param> internal void PerformSort(DataGridColumn sortColumn) { Debug.Assert(sortColumn != null, "column should not be null"); if (!CanUserSortColumns || !sortColumn.CanUserSort) { return; } if (CommitAnyEdit()) { PrepareForSort(sortColumn); DataGridSortingEventArgs eventArgs = new DataGridSortingEventArgs(sortColumn); OnSorting(eventArgs); if (Items.NeedsRefresh) { try { Items.Refresh(); } catch (InvalidOperationException invalidOperationException) { Items.SortDescriptions.Clear(); throw new InvalidOperationException(SR.Get(SRID.DataGrid_ProbableInvalidSortDescription), invalidOperationException); } } } }
/// <summary> /// Protected method which raises the sorting event and does default sort /// </summary> /// <param name="eventArgs"></param> protected virtual void OnSorting(DataGridSortingEventArgs eventArgs) { eventArgs.Handled = false; if (Sorting != null) { Sorting(this, eventArgs); } if (!eventArgs.Handled) { DefaultSort( eventArgs.Column, /* clearExistinSortDescriptions */ (Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift); } }
private void repairOrderList_Sorting(object sender, DataGridSortingEventArgs e) { e.Handled = true; }
protected virtual new void OnSorting(DataGridSortingEventArgs eventArgs) { Contract.Requires(eventArgs != null); }
private void PanelList_Sorting(object sender, DataGridSortingEventArgs e) { var view = CollectionViewSource.GetDefaultView(PanelList.ItemsSource) as ListCollectionView; if (view.IsAddingNew == true || view.IsEditingItem == true) { PanelList.CanUserSortColumns = false; } else { PanelList.CanUserSortColumns = true; } }
private static void GridOnSorting(object sender, DataGridSortingEventArgs e) { e.Handled = true; }