I am working with the sample provided in this thread: http://es.infragistics.com/community/forums/t/106614.aspx
But I got a problem: If I right click the same node twice, it shows the wrong menu item. For ex: If I right click Expand on a collapsed node, then it expands it. If I right click on it again, it shows Expands, instead of Collapse menu item. I have handled visibility in the class inside the sample project itself. But it is not working properly. please see attached image.
What is wrong with the code?
Thanks
Thank you for the sample Chris! This is definitely a step in the direction of what I want. If I wan to handle three-state checkbox, which function will I have to modify and what is the property I have to check? In my object structure, if I make IsChecked property as nullable(of Boolean) will that automatically handle three state checkbox or I have to make modifications in XAML also?
Hi Mohni,
When working with objects of different types, a NodeLayout for each type must be implemented to display hierarchical data within the XamDataTree, it is however possible to achieve this behavior with a single data object class and a single NodeLayout using an ItemTemplate for your nodes.
In in this scenario, the ItemTemplate could include a CheckBox and TextBlock for your nodes, binding the TextBlock text to the Name property off of your data object and implementing your single data object class; you would also need to manage all CheckBox interactions yourself through the code behind.
That being said, I was able to achieve this behavior with a single NodeLayout, implementing a single ‘Node’ class; while maintaining virtually the same data structure from your previous sample. This self-referencing approach also eliminated the arbitrary node elements that were previously generated when multiple NodeLayouts/target types are implemented.
I’ve attached a modified version of your earlier sample using this approach along with the necessary recursion code for managing most of the possible CheckBox states for parent/child nodes to get you started.
If you have any further questions related to this behavior, please let me know.
Warm regards,
Chris K.
OK.
If I have only one layout (one type of object only and one nested collection), is it possible to make certain nodes have independent checkbox behavior depending on a property value inside that object?
So clsParent has following properties: ID, Description, Type and ChildItems as List of clsParent. If Type is A, then node should be independent. Can it be done at all, through code or XAML?
Thanks,
The specific node selection behavior that you are interested is possible by maintaining a reference to the checked state for ChildNodes by adding an IsChecked property to your ChildNode and ParentNode classes, as well as adding a property off of the ChildNode class for keeping track of its associated parent; which is then set on the ChildNode object in your data.
Next, update the IsChecked property on your ParentNode, whenever a ChildNode’s checkbox is checked, (the checkbox within the ChildNode’s item template can be bound to the underlying IsChecked property to ensure it is updated) and the CheckBoxMemberPath will be set to the IsChecked property of ParentNode, (which itself is being set whenever a child node is checked, within your ParentNode class).
I have modified your earlier sample for achieving this behavior and attached it for further context, (as well as the XAML snippet, below).
<igDT:XamDataTree Name="OtherTree">
<igDT:XamDataTree.CheckBoxSettings>
<igDT:CheckBoxSettings CheckBoxVisibility="Visible"/>
</igDT:XamDataTree.CheckBoxSettings>
<igDT:XamDataTree.GlobalNodeLayouts>
<igDT:NodeLayout Key="ParentLayout"
TargetTypeName="ParentNode"
DisplayMemberPath="Name" CheckBoxMemberPath="IsChecked">
</igDT:NodeLayout>
<igDT:NodeLayout Key="ChildLayout"
TargetTypeName="ChildNode"
DisplayMemberPath="Name">
<igDT:NodeLayout.CheckBoxSettings>
<igDT:CheckBoxSettingsOverride CheckBoxVisibility="Collapsed">
</igDT:CheckBoxSettingsOverride>
</igDT:NodeLayout.CheckBoxSettings>
<igDT:NodeLayout.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<CheckBox IsChecked="{Binding Path=Node.Data.IsChecked}" />
<TextBlock />
</StackPanel>
</DataTemplate>
</igDT:NodeLayout.ItemTemplate>
</igDT:XamDataTree.GlobalNodeLayouts>
</igDT:XamDataTree>
There is one drawback to this implementation due to the use of nested collections within your ParentNode collection, as the XamDataTree will always display a node level for each sub-collection, using the associated NodeLayout key for the display name of that node level(s); there is currently no supported means of hiding these nodes and this secondary behavior will require a product idea.
Product ideas are used to gauge the interest for particular features that are not yet supported, (including new controls/products); product ideas which have the most number of votes become candidates for implementation and integration into Infragistics products for upcoming releases.
You may submit a product idea for this behavior by clicking the following link, (http://ideas.infragistics.com/forums/192363-wpf); you will be directed to the Infragistics product idea website, within the WPF product group. Simply enter a brief description of your idea into the suggestion box and select ‘Post a new idea…’, then within the Description dialog, provide as much detail as possible as it relates to your idea, (screenshots/mock-ups are encouraged), provide your email address in the appropriate dialog, if no yet signed in and then select the ‘Post idea’ button.
If you have any further questions that I may assist you with, please let me know.
can anyone please take a look and let me know? Thanks