Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
220
Issue on child Item Removal when Parent is Collapsed - XamdataTree
posted

I am using Infragistics V16.1 . I am giving snipped of code where the issue occurs 

Here ParentColl is ObservableCollection of TreeElement which has children of Type TreeElement bind to XamDataTree.

Xaml:

<ig:XamDataTree x:Name="MyTree" Grid.Row="0" AllowDrop="True" DisplayMemberPath="Name" ItemsSource="{Binding ParentColl}">
<ig:XamDataTree.GlobalNodeLayouts>
<ig:NodeLayout Key="ParentLayout" TargetTypeName="TreeElement" IsDraggable="True" IsDropTarget="True" DisplayMemberPath="Name"/>
</ig:XamDataTree.GlobalNodeLayouts>
</ig:XamDataTree>

On the click of a button I am trying to remove the childitem when parent is collapsed . Here is sample 

        TreeElement ChildItem = Parent.Children.FirstOrDefault();

          Parent.Children.Remove(ChildItem);

The  System.NullReferenceException  is thrown only when Parent is collapsed. Help me find a solution. 

Exception Thrown is below:       

at Infragistics.Controls.Menus.NodeLayout.UnSubscribeForNotificationsForNodeData(Object nodeData)
at Infragistics.Controls.Menus.NodesManager.DataManager_CollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
at Infragistics.DataManagerBase.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at Infragistics.DataManagerBase.OnDataSourceCollectionChanged(NotifyCollectionChangedEventArgs e)
at Infragistics.DataManager`1.OnDataSourceCollectionChanged(NotifyCollectionChangedEventArgs e)
at Infragistics.DataManagerBase.<SetDataSource>b__9(DataManagerBase instance, Object s, NotifyCollectionChangedEventArgs e)
at Infragistics.WeakEventHandler`3.OnEvent(Object source, TEventArgs eventArgs)
at System.Collections.ObjectModel.ObservableCollection`1.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
at System.Collections.ObjectModel.ObservableCollection`1.RemoveItem(Int32 index)
at System.Collections.ObjectModel.Collection`1.Remove(T item)