Hi,
I'm trying to dynamically build a XamContextMenu's XamMenuItems based on some properties of the row/cell that was clicked on in a XamDataGrid.
Based on what properties exist on my row item, I need to dynamically add several groups of XamMenuItems. I am initially using a List<XamMenuItem> to hold all the items that I need to add to the menu, but I would like to put XamMenuSeperators between the different 'groups' of my XamMenuItems. However, XamMenuSeparator is not derived from XamMenuItem and I am not sure if there is a collection that would allow me to combine XamMenuItems and XamMenuSeparators such that I could iterate over the collection and add items to my XamContextMenu dynamically?
Thank you
Hello,
If could suggest using a Dictionary instead, where you would have a key - group and value - list of menu items.
Using two foreach loops, one for the groups, one for the lists inside, and adding a separator when a group has been iterated.
I don't know how you populate your list and how you determine which item goes into what group, but I believe my suggestion should be efficient.
Having different types in the same list is not going to work well with c#, even though there are workarounds.
Please let me know if you have more questions.
Sincerely,Tihomir TonevAssociate Software DeveloperInfragistics
That's the solution I figured I'd have to settle on, but it's not ideal.
The provided approach is just one way to do it. As I do not know what issues this may bring to your application as I am not aware of all the details, should you have any concerns, please let me know.
Thank you for using Infragistics components.