This is a migrated thread and some comments may be shown as answers.

Non-static method requires a target on binding Collection to Grid

4 Answers 459 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rodrigo Rodriguez
Top achievements
Rank 1
Rodrigo Rodriguez asked on 13 Jan 2011, 02:33 PM

Binding a collection based on ICollectionView to the GridView would cause the System.Reflection.TargetException  “Non-static method requires a target” to be thrown.
That interface has a member called GroupDescriptions, that according to the MSDN “The value of this property is always a null reference”. This behaviour causes the GridViewDataControl.OnApplyTemplate chain to throw this exception.
By following the stack, the BindDescriptorsToDescriptions constructor uses the parameter right of ConvertingObservableCollectionManager.Track method, which has the parameter value set by the original ICollectionView.GroupDescriptions value, which is null.
Implementors of this Interface may not fill this value, assuming that others will do.
The example uses the class EntityCollectionView  provided by the  following article: http://blogs.msdn.com/b/brada/archive/2009/09/07/business-apps-example-for-silverlight-3-rtm-and-net-ria-services-july-update-viewmodel.aspx.

A check on the availability of the GroupDescriptions would be provided.

 
Here is the stack trace:

 

Telerik.Windows.Data!Telerik.Windows.Data.WeakEvent.WeakListener<System.Collections.Specialized.NotifyCollectionChangedEventArgs>.Listen<System.Collections.Specialized.INotifyCollectionChanged>(sender, eventName) Line 48 Telerik.Windows.Data!Telerik.Windows.Data.WeakEvent.InternalSubscribe<System.Collections.Specialized.INotifyCollectionChanged,System.Collections.Specialized.NotifyCollectionChangedEventArgs>(eventName, sender, listener) Line 85
  
Telerik.Windows.Data!Telerik.Windows.Data.WeakEvent.Subscribe<System.Collections.Specialized.INotifyCollectionChanged,System.Collections.Specialized.NotifyCollectionChangedEventArgs>(eventName, sender, listener) Line 90 + 0x37 bytes         C#
  
Telerik.Windows.Data!Telerik.Windows.Data.ObservableCollectionManager.ObservableCollectionManager(left, right) Line 59 + 0x20 bytes
  
Telerik.Windows.Data!Telerik.Windows.Data.ObservableCollectionManager.Track(left, right, comparer) Line 46 + 0x1d bytes
  
Telerik.Windows.Data!Telerik.Windows.Data.DataItemCollection.BindCollections(localCollection, foreignCollection, comparer) Line 829 + 0x10 bytes
  
Telerik.Windows.Data!Telerik.Windows.Data.DataItemCollection.SetItemsSource(source) Line 743
  
Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewDataControl.Bind.AnonymousMethod__17() Line 3511
  
Telerik.Windows.Controls!Telerik.Windows.Controls.CursorManager.PerformTimeConsumingOperation(frameworkElement, action) Line 16 + 0xb bytes
  
Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewDataControl.Bind(newValue) Line 3540
  
Telerik.Windows.Controls.GridView!Telerik.Windows.Controls.GridView.GridViewDataControl.OnApplyTemplate() Line 2931

4 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 18 Jan 2011, 05:19 PM
Hi Rodrigo Rodriguez,

A similar problem in our OpenAccess ORM was fixed long time ago.

Still, we cannot tell what is the exact problem unless we debug your project. Can you please isolate the problem in a sample application and send it to us in a separate ticket? It will help us to identify the reason.

Kind regards,
Veselin Vasilev
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Rodrigo Rodriguez
Top achievements
Rank 1
answered on 18 Jan 2011, 10:41 PM
The problem is not happing anymore because we have provided a valid GroupDescriptions to the ICollectionView derived class.
So the sugestion is: A check on the availability of the GroupDescriptions would be provided.
A solution is to update the BindDescriptorsToDescriptions constructor to check the if GroupDescriptions is provided by the ICollectionView that is bound to the Grid.
To reproduce: You can build a sample that uses a class that extends ICollectionView. Return NULL on the GroupDescriptions member. And bound it to the Grid.
0
Ganesh Shivshankar
Top achievements
Rank 1
answered on 20 Sep 2011, 06:29 AM
This is happening with the latest build as well. I'm having to set the GroupDescriptors to a empty collection now to get it working. This was not a issue earlier.
0
Philip
Top achievements
Rank 1
answered on 18 Dec 2012, 02:01 PM
I know this is an old thread but I am having this issue as well in Silverlight 4.

How did you guys manage to set GroupDescriptors since it is a readonly property?
Tags
GridView
Asked by
Rodrigo Rodriguez
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Rodrigo Rodriguez
Top achievements
Rank 1
Ganesh Shivshankar
Top achievements
Rank 1
Philip
Top achievements
Rank 1
Share this question
or