Hello, I have a XamDataTree defined as follows:
<ig:XamDataTree x:Name="_MenuTree" ItemsSource="{Binding Menus}" SelectedDataItems="{Binding SelectedMenuItems}" NodeLineVisibility="Visible" IsExpandedMemberPath="IsExpanded" NodeCheckedChanged="TreeNodeCheckedChanged"> <ig:XamDataTree.CheckBoxSettings> <ig:CheckBoxSettings CheckBoxVisibility="Visible" CheckBoxMode="Auto" /> </ig:XamDataTree.CheckBoxSettings> <ig:XamDataTree.SelectionSettings> <ig:TreeSelectionSettings NodeSelection="Multiple" /> </ig:XamDataTree.SelectionSettings> <ig:XamDataTree.GlobalNodeLayouts> <ig:NodeLayout Key="MenuLayout" TargetTypeName="clsMenuItem" DisplayMemberPath="Description" CheckBoxMemberPath="IsSelected"> </ig:NodeLayout> </ig:XamDataTree.GlobalNodeLayouts> </ig:XamDataTree>
The Menus property is in the ViewModel and is an ObservableCollection of clsMenuItem. clsMenuItem has the following properties: ID (int), Description (string) and ChildItems (ObservableCollection(of clsMenuItem))
I looked at one of the other similar posts on the forums board, but in my case, I don't see anything on the screen when then form loads, even though the Menus property has proper stuff in it.
What am I missing / doing wrong?
Yep. That small changed worked fine. But if I uncheck a node, I get this exception on the RaiseEvent line in clsMenuItem:
An exception of type 'System.NullReferenceException' occurred in InfragisticsWPF4.Controls.Menus.XamDataTree.v15.2.dll but was not handled in user code
Additional information: Object reference not set to an instance of an object.
Treenode checked changed fires multiple times depending on how may levels of child are there. Please see modified sample. I have added messageboxes in the event function to see which node gets parsed first and in what order.
Is there a way to find out when the parsing is done on all nodes? I understand it is doing multiple checkedchanged event, because checking / unchecking on one node affects some other node (parent / child).
Also, if you check the root node with two levels of child, the root node is added 1 time, the level 1 parent is added 2 times and the child is added 3 times in the SelectedTree. If I can find when the parsing on all related nodes is complete, I can maybe recursively get rid of duplicate nodes?!!
Thanks,
Manasi
Hello Manasi,
I am glad that the sample project I had provided you clears things up for you.
The reason that the "SelectedMenuTree" is not being populated is because although the data tree nodes in your left-hand side XamDataTree are checked, that doesn't necessarily mean that they are selected - it only means that they are "checked". You can see this by examining the SelectedMenuItems collection that you have bound to your XamDataTree.SelectedDataItems property at runtime. On load of the XamDataTree, this collection appears to be empty. If you click on one of the nodes, it will get selected, and you should see your other tree show up correctly.
If you want the checked nodes to correspond directly to the selected nodes, I would recommend that you set the IsSelectedMemberPath property of your XamDataTree's NodeLayout to the same property that your CheckBoxMemberPath is set to. This will select the nodes in your XamDataTree as long as those nodes are checked. In the case of the sample project that exists on this forum thread, the code for this would look like the following:
<ig:NodeLayout Key="MenuLayout" TargetTypeName="clsMenuItem" DisplayMemberPath="Description" CheckBoxMemberPath="IsSelected" IsSelectedMemberPath="IsSelected" >
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
Hi Andrew, thanks for setting me right. I just ran the sample you sent and from the code behind, a lot of things are clear now. However, the SelectedMenuTree still doesn't show up. Did it work on your side? Has it something to do with any reference that I am not adding? I have attached a screenshot of the form when I ran your VBNET sample.
I have been looking over the sample project that you have sent, and currently, it appears that the reason that the sample isn't working correctly is because the DataContext of the window and its containing elements is not set. It also appears that the namespace definitions in a couple of the classes is incorrect as well. From my perspective, it looks like what you were looking to create was a direct VB.NET modeling of the C# project that Valerie sent, and so I have attached a working VB.NET example of the sample Valerie created to this post. You should see that in this sample project, since the data context has been corrected, the "RaiseEventPropertyChanged" part of the clsMenuItem class does get fired for the properties that change in the XamDataTree.
Regarding your most recent question, you will need to do a recursive search to include the parent hierarchy in the ItemsSource of the secondary XamDataTree. The secondary XamDataTree cannot include the hierarchy from the first tree by only having the child node in its collection. You may also need to include a separate node layout for your secondary tree, but I'm not entirely sure on this at the moment. I am going to continue looking into this, and I will update the sample that is attached to this post when I have more information for you on this matter.
Hi Valerie,
Thanks for the sample. I created a similar one in VB as I am working in VB.NET. Doesn't seem to work. Please take alook and let me know what I am doing wrong.
The "RaiseEvent PropertyChanged" doesn't do anything. Should I be writing a handler of my own, or does DataTree know what it's supposed to do?
If you need more information or changes to my sample, please let me know. This is first time I am using this control.
Question: If I select a child node on the Main Tree, how can I get the Selected Tree to show the child with the it's parent hierarchy? Is it a property I can set or do I have to do a recursive search to include the parent in the second tree?
Thanks,Manasi