This is a migrated thread and some comments may be shown as answers.
RadTreeView - [ERROR] FATAL UNHANDLED EXCEPTION: System.NullReferenceException
4 Answers 26 Views
This is a migrated thread and some comments may be shown as answers.
n/a
Top achievements
Rank 1
n/a asked on 22 May 2018, 01:00 PM

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

4 Answers, 1 is accepted

Sort by
0
n/a
Top achievements
Rank 1
answered on 22 May 2018, 02:16 PM

Git source code for sample.

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

0
n/a
Top achievements
Rank 1
answered on 22 May 2018, 04:43 PM

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 
0
n/a
Top achievements
Rank 1
answered on 22 May 2018, 06:01 PM

I just find out what was wrong,

TreeView need to create nested ViewModel containing items source collection.

0
Lance | Manager Technical Support
Telerik team
answered on 22 May 2018, 07:08 PM
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
Asked by
n/a
Top achievements
Rank 1
Answers by
n/a
Top achievements
Rank 1
Lance | Manager Technical Support
Telerik team
Share this question
or