Hi,
i have a question regarding the xamtreegrid in combination with the context menu. I have created a context menu for the different elements in the tree.
Thererore, if i click on such a element i get the element with the GetClickedElements() method in the opening event and according to the specific
element i change the visibilies of the different context menu items. This works pretty fine for me. Additionally if i do not click on a specific element (click on the white background of the xamTreegrid Control => GetClickedElements() returns zero clicked elements), i show different context menu items for the tree.
The main problem now is, if i expand all records in the tree with xTree.Records.ExpandAll(true) and the collapse all records with xTree.Records.CollapseAll(true), the context menu does not work correctly. Now if i click only into the white tree view control and not on a specific field the GetClickedElements() method in the context menu opening window returns now the element that was shown at this position after all records were expanded! So maybe there is a problem inside the xTree.Records.CollapseAll(true).
So how can i refresh the tree after collapsing all records in order to avoid this problem? Or are there other solutions?
Many thanks in advance!
BR Rene
Hello Rene,
Thank you for your post.
I have been looking into your issue and what I can suggest is to call the UpdateLayout method of XamTreeGrid after calling the xTree.Records.ExpandAll(true) and also after xTree.Records.CollapseAll(true). You can read more details about UpdateLayout method from the following link:
https://msdn.microsoft.com/query/dev10.query?appId=Dev10IDEF1&l=EN-US&k=k(System.Windows.UIElement.UpdateLayout)&rd=true
Please let me know if I am missing something from your scenario and do not hesitate to ask if you have any questions regarding this matter.
Thank you for using Infragistics Components!
Thank you for your reply!
Adding the UpdadeLayout call after both methods does not fix the problem. I still get an element from the e.GetClickedElements() method if i click on the
empty background after i expand and collapse the nodes from the tree..
BR,
Rene
I have been looking into it, but it seems like I am missing something from your scenario, so if this is still an issue for you, could you please send me, an isolated sample project, where this is reproduced, so I can investigate it further for you.
Looking forward to hearing from you.
Now i have created an example project.
After starting the application only the clusters are shown. Now if you click on the white background a context menu appears with only one entry (Add new cluster)
If you expand the last cluster and collapse it again, the context menu looks now different. The same context menu appears if you click directly on the activity.
Thanks!
I have been looking into the sample applciaiton you have provided and it seems that the e.GetClickedElements<DataRecordPresenter>() method returns the DataRecordPresenters from visual tree,even if their Visibility property is set to Collasped, so when you expand the nodes DataRecordPresenter for child elements are loaded and then if you collapse the nodes ther’s Visibility property is set to Collapsed but they exist in the visual tree. This way when you click on the white background with cordinates equal to child records the GetClickedElements method returns these records.
What I can suggest is to iterate through the records in your elements collection and return only the records with Visibility equal to Visible.
For example:
var elements = e.GetClickedElements<DataRecordPresenter>();
if (elements.FindAll(drp => drp.Visibility == System.Windows.Visibility.Visible).Count > 0)
{
// do your logic here
}
Please let me know if you require any further assistance regarding this matter.
Thank you for your quick answer! Now everthing works fine!
Great support!
I am really glad, I could help out. If you have any further questions, please do not hesitate to let me know.