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

5 posts, 0 answers
  1. Rodrigo Rodriguez
    Rodrigo Rodriguez avatar
    4 posts
    Member since:
    Dec 2009

    Posted 13 Jan 2011 Link to this post

    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:

    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

  2. Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 18 Jan 2011 Link to this post

    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>>
  3. Rodrigo Rodriguez
    Rodrigo Rodriguez avatar
    4 posts
    Member since:
    Dec 2009

    Posted 18 Jan 2011 Link to this post

    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.
  4. Ganesh Shivshankar
    Ganesh Shivshankar avatar
    78 posts
    Member since:
    Sep 2009

    Posted 20 Sep 2011 Link to this post

    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.
  5. Philip
    Philip avatar
    1 posts
    Member since:
    Jan 2011

    Posted 18 Dec 2012 Link to this post

    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?
Back to Top