Exception while adding Nodes/Childs in a Tree

3 posts, 0 answers
  1. Syed Asif
    Syed Asif avatar
    10 posts
    Member since:
    Nov 2009

    Posted 09 Nov 2011 Link to this post


    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;

    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. Syed Asif
    Syed Asif avatar
    10 posts
    Member since:
    Nov 2009

    Posted 09 Nov 2011 Link to this post

    Can I have the update on this Issue please, need an urgent solution as this is becoming a blocker for my application.
  3. Petar Mladenov
    Petar Mladenov avatar
    3162 posts

    Posted 14 Nov 2011 Link to this post

    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 >>

Back to Top