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