I am working with the sample provided in this thread: http://www.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
I tried to paste code in my previous question, but there was some problem. So I am attached the project here.
Hi Mohni,
I’ve constructed and attached a sample specifically demonstrating the behavior that you are interested in.
Please let me know if you have any questions regarding this approach or if you have any further questions that I may assist you with.
Warm regards,
Chris
Hi Chris,
Thank you for the sample. But I see you are not using a visibility converter. Is it possible to make it work with the visibility converter?
I tried to use your way in my project, with the help of ContextMenu_Opening function. Problem is, I cannot access the Menuitems in the contextmenu by name, I have to hard-code the index to set visibility of all four items. Like 0 = Expand, 1 = Collapse, etc.
I also cannot use ig:XamContextMenu, it has to be normal ContextMenu like the sample project I attached. So if I have contextmenu on XamDataTree, it has to always be XamContextMenu?
I have another question, since your sample demonstrated what I am doing anyway: I have the following kind of structure:
clsCategory { categoryID, categoryName, description, Products }
clsProduct { productID, productName, categoryID, quantityPerUnit, ProductOptions }
clsProductOption { productID, productoptionID, optionName }
Is it possible to have checkboxmode = Auto for Category and Product but not for Productoption? So, user can have a Product selected, without any Option. But if Product is selected, Category should get updated.
UPDATE: With Checkbox Mode Auto, is it possible to stop the TreeNodeCheckedChanged event from firing if the type is ProductOption? I want to be able to select a Product node, even if none or some of the Options are checked or unchecked. I tried to handle it in the NodeCheckChanged event, but that's after the node's IsChecked property is updated.
The XamDataTree does not support discrete adjustment of the CheckBoxMode per node level within the node hierarchy or NodeLayout, (there is a CheckBoxSettingsOverride exposed from NodeLayout, but this is limited to applying discrete style and visibility for the associated checkbox).
This behavior may be possible, but would require a custom implementation; one possible approach could include applying CheckBoxVisibility to Visible and CheckboxMode of ‘Auto’ on the XamDataTree and hiding Checkboxes for the NodeLayout that you’ve defined for ProductOption, then creating an item template specifically for that NodeLayout to include its own Checkbox. The idea here would be that Checkboxes for this node level would behave independently, not selecting when an ancestor node is selected, and you could handle the checked state of these Checkboxes to also activate the checked state for its ancestor nodes.
I’ve included the following link for our documentation which details supported behaviors for the built in CheckBoxes available with the XamDataTree:
http://help.infragistics.com/doc/WPF/2016.1/CLR4.0/?page=xamDataTree_xamDataTree_Check_Boxes.html
And this link for further context on implementing customized NodeLayouts:
http://help.infragistics.com/doc/WPF/2016.1/CLR4.0/?page=xamDataTree_xamDataTree_Node_Layouts.html
You don’t necessarily need to use the XamContextMenu for obtaining the same behavior in your previous post, but it was the most convenient to use in this case and including built-in support for handing/cancelling its ContextMenu_Opening event and would require less code to implement.
Please let me know if you have any further questions.
thanks for the suggestion. I will try it and let you know. Can you elaborate on what you mean by "then creating an item template specifically for that NodeLayout to include its own Checkbox."
Do you have a sample or link to do this?
EDIT: I added two layouts, with CheckBoxVisibility off like you said, but now I get extra levels like "CategoryLayout" and "OptionsLayout"? How to get rid of these? If there are no options in the list of products, then I get an empty "OptionsLayout" level, with nothing under it.
EDIT: I have attached a sample to demonstrate my object behavior. If you look at the sample, you will see that, clsSubItem is a property of clsItem. clsSubItem can be either A or B. The nodes that bind to clsItem.SubItemB should be independent.
thanks
Chris,
I changed my object structure a little, to work with two layouts. I have attached that project here. I am not sure that my functionality is possible with which sample project, but any pointers will help. In this scenario, I get empty nodes for each layout if the underlying property does not have any items in it.
Kindly let me know which object structure is best suited for my requirement. Basically, clsSubItemB type nodes should be independent of the rest of the tree. Should they be exposed as list property of clsItem or wrapped in clsItem inside list of clsItem? I am not sure yet, how they layout works stuff out.
Please take a look at the two samples and let me know which structure is the best suited. Also, I did not find an ItemTemplate for NodeLayout in the help files. Can you send me a link or modify one of my samples?
thanks.
Hi Chris, I created an ItemTemplate like you said and also specified CheckboxVisibility = Collapsed on the second NodeLayout. But it does not work.
Please check what is wrong. Also, When I check/uncheck the template checkbox, I go to the function specified, but how can I get the Node associated in that function?
Again, there was some problem pasting code. So I have attached the new project here. In this project, I still get the "ItemLayout" and "SubItemLayout" nodes. How to get rid of those? And even if I set CheckBoxVisibility to Collapsed on the second node layout, it shows up still.
Thanks,