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

Exception while adding Nodes/Childs in a Tree

2 Answers 69 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Syed Asif
Top achievements
Rank 1
Syed Asif asked on 09 Nov 2011, 12:43 PM
Hi,

With the new Silverlight 5 RC released I was trying to run my developed Silverlight 4 application with Silverlight 5 RC, but unfortunately I could not run it and this gave me lot of exceptions. Note: My application with Tree View is working perfectly on the machines where  Silverlight 4 is installed, but gives exceptions on Silverlight 5 RC. When I debugged it and found that there is some problem when I am trying to add a child to the created root.

Below is the code snippet for my process of adding child to a root item

                RadTreeViewItem headerItem = new RadTreeViewItem();
                headerItem.Style = (Style)Application.Current.Resources["TreeViewRootStyle"];
                headerItem.Header = root.ItemName;
                if (root.IconCode != null)
                {
                    imgSrc.Source = new BitmapImage(new Uri(root.IconCode, UriKind.Relative));
                    headerItem.DefaultImageSrc = imgSrc.Source;
                }
                foreach (NavigationItemLink item in root.ChildItems)
                {
                    RadTreeViewItem childItem = new RadTreeViewItem();
                    if (item.IconCode != null)
                    {
                        imgSrc.Source = new BitmapImage(new Uri(item.IconCode, UriKind.Relative));
                        childItem.DefaultImageSrc = imgSrc.Source;
                    }
                    childItem.Style = (Style)Application.Current.Resources["TreeViewNodeStyle"];
                    childItem.Header = item.ItemName;
                    childItem.Tag = item.Delegate;
                    headerItem.Items.Add(childItem);
                }


Exception Details:

Exception Raised at the line headerItem.Items.Add(childItem);

{System.Exception: Exception: Value cannot be null.
Parameter name: element ---> System.ArgumentNullException: Value cannot be null.
Parameter name: element
   at MS.Internal.XcpImports.ItemsControl_GetItemsOwner(DependencyObject element)
   at System.Windows.Controls.ItemsControl.ItemsControlFromItemContainer(DependencyObject container)
   at Telerik.Windows.Controls.ItemsControl.ItemsControlFromItemContainer(DependencyObject container)
   at Telerik.Windows.Controls.RadTreeViewItem.SearchForParentTreeView()
   at Telerik.Windows.Controls.RadTreeViewItem.UpdateCheckStateAfterItemsChange(RadTreeViewItem containerItem, ToggleState state)
   at Telerik.Windows.Controls.RadTreeViewItem.OnItemsChanged(NotifyCollectionChangedEventArgs e)
   at System.Windows.Controls.ItemsControl.OnItemCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Collections.Specialized.NotifyCollectionChangedEventHandler.Invoke(Object sender, NotifyCollectionChangedEventArgs e)
   at System.Windows.Controls.ItemCollection.NotifyCollectionChanged(NotifyCollectionChangedEventArgs e)
   at System.Windows.Controls.ItemCollection.AddImpl(Object value)
   at System.Windows.Controls.ItemCollection.AddInternal(Object value)
   at System.Windows.PresentationFrameworkCollection`1.Add(T value)


Please suggest a solution for the above problem.

Thanks and Regards,
Syed Asif

2 Answers, 1 is accepted

Sort by
0
Syed Asif
Top achievements
Rank 1
answered on 10 Nov 2011, 05:56 AM
Can I have the update on this Issue please, need an urgent solution as this is becoming a blocker for my application.
0
Petar Mladenov
Telerik team
answered on 14 Nov 2011, 10:40 AM
Hello Syed Asif,

There are certain issues we're having against the publicly available SL5 RC version. These issues are now resolved thanks to our close cooperation with Microsoft. However, since there isn't a more recent official version rather than SL5 RC, we cannot officially announce anything till the SL5 RTM is out.
Thank you for your understanding.

All the best,
Petar Mladenov
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
TreeView
Asked by
Syed Asif
Top achievements
Rank 1
Answers by
Syed Asif
Top achievements
Rank 1
Petar Mladenov
Telerik team
Share this question
or