RadTreeView - [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException

5 posts, 0 answers
  1. Maciej Poskrop
    Maciej Poskrop avatar
    9 posts
    Member since:
    Feb 2018

    Posted 22 May 2018 Link to this post

    I started using RadTreeView, so I added XAML reference and tree to page, and corresponding collection in viewmodel.

    After add Item to collection I got exception as below:

    05-22 14:54:25.831 E/mono-rt ( 4107): [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException: Object reference not set to an instance of an object.  
    at Telerik.XamarinForms.DataControls.RadTreeView.UpdateParentItemOnAddRemove
      
    at Telerik.XamarinForms.DataControlsRenderer.Android.TreeViewRenderer.LayoutItemAdded

    at Telerik.XamarinForms.DataControls.TreeView.TreeViewLayout.RaiseLayoutItemAdded
      
    at Telerik.XamarinForms.DataControls.TreeView.TreeViewLayout.AddItem
     
    at Telerik.XamarinForms.DataControls.TreeView.TreeViewLayout.OnCollectionChanged

    at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged
  2. Maciej Poskrop
    Maciej Poskrop avatar
    9 posts
    Member since:
    Feb 2018

    Posted 22 May 2018 in reply to Maciej Poskrop Link to this post

    Git source code for sample.

    git clone https://brzezinol2@bitbucket.org/brzezinol2/prismteleriktest.git

  3. Maciej Poskrop
    Maciej Poskrop avatar
    9 posts
    Member since:
    Feb 2018

    Posted 22 May 2018 in reply to Maciej Poskrop Link to this post

    I investigate more and I found hidden exception:

    {System.InvalidOperationException: Iterating over item that was iterated...
      at Telerik.XamarinForms.DataControls.TreeView.TreeViewLayout.PopulateTable 
      at Telerik.XamarinForms.DataControls.TreeView.TreeViewLayout.PopulateTable 
      at Telerik.XamarinForms.DataControls.TreeView.TreeViewLayout.PopulateTable 
      at Telerik.XamarinForms.DataControls.TreeView.TreeViewLayout.AddItem 
      at Telerik.XamarinForms.DataControls.TreeView.TreeViewLayout.OnCollectionChanged 
      at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged 
      at System.Collections.ObjectModel.ObservableCollection`1[T].OnCollectionChanged 
      at System.Collections.ObjectModel.ObservableCollection`1[T].InsertItem 
      at System.Collections.ObjectModel.Collection`1[T].Add (T item) 
      at PrismTelerikTest.ViewModels.TelerikTreeViewPageViewModel.OnNavigatingTo 
  4. Maciej Poskrop
    Maciej Poskrop avatar
    9 posts
    Member since:
    Feb 2018

    Posted 22 May 2018 in reply to Maciej Poskrop Link to this post

    I just find out what was wrong,

    TreeView need to create nested ViewModel containing items source collection.

  5. Lance | Manager Technical Support
    Admin
    Lance | Manager Technical Support avatar
    1168 posts

    Posted 22 May 2018 Link to this post

    Hello Maciej,

    I'm glad you were able to find a solution. You're correct, there should be an item adapter that tells the TreeView where to get the nested items, which are typically located within the same model definition. Take a look at the Getting Started Example for more guidance.

    Regards,
    Lance | Tech Support Engineer, Sr.
    Progress Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top