We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfDatagrid Exception when sorting

Thread ID:





130158 Apr 25,2017 09:08 PM UTC May 2,2017 12:43 PM UTC WPF 4
Tags: SfDataGrid
Oto Dusek
Asked On April 25, 2017 09:08 PM UTC

I modified SfDataGrid, so the datagrid assign new ItemsSource of the datagrid, when it sort rows by clicking on datagrid header.

but i updated nuget packages, now it throws exception on line 31 (see attachment):
ItemsSource = l;

I can fill ItemsSource till I click on the header of the datagrid, then it throws following exception:

   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
   at Syncfusion.Data.CollectionViewAdv.EndDeferInternal()
   at Syncfusion.Data.CollectionViewAdv.EndDefer()
   at Syncfusion.Data.CollectionViewAdv.DeferHelper.Dispose(Boolean isDisposing)
   at Syncfusion.Data.CollectionViewAdv.DeferHelper.Dispose()
   at Syncfusion.Data.CollectionViewAdv.Dispose(Boolean isDisposing)
   at Syncfusion.UI.Xaml.Grid.GridQueryableCollectionViewWrapper.Dispose(Boolean isDisposing)
   at Syncfusion.Data.CollectionViewAdv.Dispose()
   at Syncfusion.UI.Xaml.Grid.SfDataGrid.DisposeViewOnItemsSourceChanged()
   at Syncfusion.UI.Xaml.Grid.SfDataGrid.OnItemsSourceChanged(DependencyObject obj, DependencyPropertyChangedEventArgs args)
   at Syncfusion.UI.Xaml.Grid.GridPropertyMetadata.OnDependencyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at Syncfusion.UI.Xaml.Grid.GridPropertyMetadata.OnInternalDependencyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e)
   at System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args)
   at System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType)
   at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
   at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
   at Syncfusion.UI.Xaml.Grid.SfDataGrid.set_ItemsSource(Object value)
   at My.Controls.EDataGrid.<fillDataGridAsync>d__19.MoveNext() in D:\Projects\CustomControls\CustomControls\DataGrid\EDataGrid.cs:line 186

I installed this nuget packages:  <package id="Syncfusion.Data.WPF46" version="" targetFramework="net461" />
  <package id="Syncfusion.SfGrid.WPF46" version="" targetFramework="net461" />
  <package id="Syncfusion.SfGridCommon.WPF46" version="" targetFramework="net461" />
  <package id="Syncfusion.Shared.WPF46" version="" targetFramework="net461" />

IDE: Visual studio 2015, 2017
OS: Windows 10 64 bit

Do you know where might be problem?

Oto Dusek
Replied On April 25, 2017 09:10 PM UTC

Sorry attachment doesn't work, so there is source code
public sealed class EDataGrid : SfDataGrid{
 SortColumnDescriptions scd = new SortColumnDescriptions();
 private void EDataGrid_SortColumnsChanged(object sender, GridSortColumnsChangedEventArgs e)
  SortColumnDescriptions = scd;
 private void EDataGrid_SortColumnsChanging(object sender, GridSortColumnsChangingEventArgs e)
  if (e.AddedItems.Any()) {
   args.SortColumn = e.AddedItems[0].ColumnName;
   args.SortDirection = e.AddedItems[0].SortDirection;
  } else {
   args.SortDirection = ListSortDirection.Ascending;
  foreach (var a in e.AddedItems) {
  foreach (var a in e.RemovedItems) {
 private async void fillDataGridAsync() {
  var l = await rep.GetPageAsync(args);
  ItemsSource = l;

Balamurugan Rajaraman [Syncfusion]
Replied On April 26, 2017 02:49 PM UTC

Hi Oto 
Thank you for contact Syncfusion support 
We have checked your query “Exception raised when applying sorting”. We were unable to reproduce the reported issue from our side.  We have attached the tested sample for your reference. Could you please revert us by modified the sample to reproduce the reported issue at our end. It will greatly helpful for us to analyze further. 
Balamurugan R  

Oto Dusek
Replied On April 27, 2017 07:05 PM UTC

Sorry, I cant reproduce it on other project.

Balamurugan Rajaraman [Syncfusion]
Replied On May 2, 2017 12:43 PM UTC

Hi Oto,  
We have analyzed your query and we have created a support incident to track the status of this forum has been created under your account. Please log on to our support website to check for further updates  
Balamurugan R  


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon