Hello!
In my application I am trying to sort columns of grouped dynamic objects (e.g. implementing IDynamicMetaObjectProvider). It works fine until I try to sort a column of a grouped list, throwing a null exception in private static IEnumerable<PropertyDescriptor> GetPropertyDescriptorsForDynamicType(QueryableCollectionView collectionView) in ItemPropertyInfoHelper.cs:
Telerik.Windows.Data.dll!Telerik.Windows.Data.ItemPropertyInfoHelper.GetPropertyDescriptorsForDynamicType(Telerik.Windows.Data.QueryableCollectionView collectionView) Line 184 + 0x30 bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.ItemPropertyInfoHelper.GetPropertyDescriptors(Telerik.Windows.Data.QueryableCollectionView collectionView) Line 86 + 0x1a bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.ItemPropertyInfoHelper.CreateItemProperties(Telerik.Windows.Data.QueryableCollectionView collectionView) Line 41 + 0xa bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.GetItemProperties() Line 38 + 0xa bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.ItemProperties.get() Line 29 + 0x14 bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.DataItemCollection.ItemPropertiesAreDifferent(Telerik.Windows.Data.QueryableCollectionView newCollectionView, Telerik.Windows.Data.QueryableCollectionView oldCollectionView) Line 216 + 0x35 bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.DataItemCollection.CollectionView.set(Telerik.Windows.Data.QueryableCollectionView value) Line 103 + 0x16 bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.DataItemCollection.CreateAndSetCollectionView(System.Collections.IEnumerable source) Line 932 + 0x3a bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.DataItemCollection.SetItemsSource(System.Collections.IEnumerable source) Line 713 C#
Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.GridViewDataControl.Bind.AnonymousMethod__17() Line 3646 C#
Telerik.Windows.Controls.dll!Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(System.Windows.FrameworkElement frameworkElement, System.Action action) Line 16 + 0xf bytes C#
Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(object newValue) Line 3675 C#
Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsSourceChanged(object oldValue, object newValue) Line 3267 + 0x15 bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Controls.DataControl.OnItemsSourcePropertyChanged(System.Windows.DependencyObject origin, System.Windows.DependencyPropertyChangedEventArgs args) Line 144 C#
The problem is that GetPropertyDescriptorsForDynamicType accesses the first element in the collectionview and tries to cast it to an IDynamicMetaObjectProvider:
When grouping the first element is of type AggregateFunctionsGroup and not of Type ElementType (which made the code branch into this function in the first place). To get the correct dynamic object, the line would have to be changed to get the first element of the first group that has elements but no children (or something similiar)..
I could use an ITypedList in order to not branch into GetPropertyDescriptorsForDynamicType, but it should work this way as well.
I have tried the latest internal build, but the problem remains.
Can you reproduce this problem?
Kind Regards,
Karin Huber
In my application I am trying to sort columns of grouped dynamic objects (e.g. implementing IDynamicMetaObjectProvider). It works fine until I try to sort a column of a grouped list, throwing a null exception in private static IEnumerable<PropertyDescriptor> GetPropertyDescriptorsForDynamicType(QueryableCollectionView collectionView) in ItemPropertyInfoHelper.cs:
Telerik.Windows.Data.dll!Telerik.Windows.Data.ItemPropertyInfoHelper.GetPropertyDescriptorsForDynamicType(Telerik.Windows.Data.QueryableCollectionView collectionView) Line 184 + 0x30 bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.ItemPropertyInfoHelper.GetPropertyDescriptors(Telerik.Windows.Data.QueryableCollectionView collectionView) Line 86 + 0x1a bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.ItemPropertyInfoHelper.CreateItemProperties(Telerik.Windows.Data.QueryableCollectionView collectionView) Line 41 + 0xa bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.GetItemProperties() Line 38 + 0xa bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.QueryableCollectionView.ItemProperties.get() Line 29 + 0x14 bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.DataItemCollection.ItemPropertiesAreDifferent(Telerik.Windows.Data.QueryableCollectionView newCollectionView, Telerik.Windows.Data.QueryableCollectionView oldCollectionView) Line 216 + 0x35 bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.DataItemCollection.CollectionView.set(Telerik.Windows.Data.QueryableCollectionView value) Line 103 + 0x16 bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.DataItemCollection.CreateAndSetCollectionView(System.Collections.IEnumerable source) Line 932 + 0x3a bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Data.DataItemCollection.SetItemsSource(System.Collections.IEnumerable source) Line 713 C#
Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.GridViewDataControl.Bind.AnonymousMethod__17() Line 3646 C#
Telerik.Windows.Controls.dll!Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(System.Windows.FrameworkElement frameworkElement, System.Action action) Line 16 + 0xf bytes C#
Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(object newValue) Line 3675 C#
Telerik.Windows.Controls.GridView.dll!Telerik.Windows.Controls.GridView.GridViewDataControl.OnItemsSourceChanged(object oldValue, object newValue) Line 3267 + 0x15 bytes C#
Telerik.Windows.Data.dll!Telerik.Windows.Controls.DataControl.OnItemsSourcePropertyChanged(System.Windows.DependencyObject origin, System.Windows.DependencyPropertyChangedEventArgs args) Line 144 C#
The problem is that GetPropertyDescriptorsForDynamicType accesses the first element in the collectionview and tries to cast it to an IDynamicMetaObjectProvider:
var dynamicObject = collectionView.ElementAt(0) as System.Dynamic.IDynamicMetaObjectProvider; var metaObject = dynamicObject.GetMetaObject(System.Linq.Expressions.Expression.Constant(dynamicObject));
When grouping the first element is of type AggregateFunctionsGroup and not of Type ElementType (which made the code branch into this function in the first place). To get the correct dynamic object, the line would have to be changed to get the first element of the first group that has elements but no children (or something similiar)..
I could use an ITypedList in order to not branch into GetPropertyDescriptorsForDynamicType, but it should work this way as well.
I have tried the latest internal build, but the problem remains.
Can you reproduce this problem?
Kind Regards,
Karin Huber