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)
Hi Infragistics Team,
at our company we are currently considering updating to the newest version of infragistics.
We just tried out the latest trial version and discovered the same problem as being described here.
In your last comment you wrote, that this issue should be fixed in the service release.
The fix for this problem is very important for our application.
So we can only upgrade to the latest version when this is fixed and we would like to test it with a trial version before.
Can you give us an estimation when will be the next service release?
Best regards
Joerg Naumann
Hello Vetriselvan,The NullReferenceException which occurred when removing a node and is reproduced with 16.1.20161.2056 has already been fixed internally and will be included in the next service release. I have linked this case to Development Issue 221815 so that you will be notified when the service release is available. Let me know if you have any questions.
Adding the Version I am Using
16.1.20161.2056
RunTime Version : v4.0.30319
Are we both using the same version?
I just ran the sample without any modification as you have given.
The same exception "Object reference not set to an instance of an object" occurs at the line
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) at XamDataTreeDeleteNode.MainWindow.btnDelete_Click(Object sender, RoutedEventArgs e)
I guess the child element is not available as virtualization is on
Is there any way you can turn off virtualization by a flag?
Let me know if any solution is there
Hello Vetriselvan,I have put together a sample project using the code snippets you shared. The child node of the second parent is deleted when the user clicks the Delete button. Since in the code snippet the item is removed from the source collection, the XamDataTree node is deleted without any exceptions. Please feel free to use the sample project as a starting point when implementing this functionality. And do not hesitate to let me know if you have any questions or concerns.