I want to dynamically generate a context menu when a user selects an item in list box. As recommended in this post I created a ViewModel class to represent my menu items and a then used data binding and a HierarchicalDataTemplate to help display these items in my viewModel. I had to jump through some hoops to get bind my commands, but I managed to get it work work.
However, I would like to be able to include separators in my dynamically generated context menu. To accomplish this I created different viewModel classes to represent menu items and menu separators, respectively. Now I'm stuck on how to get the XamContextMenu to select the appropriate DataTemplate based on the actual type of each object in the bound collection.
I tried using a custom DataTemplateSelector, but that didn't work. I suspect that this is because the HierarchicalDataTemplate that is used by XamContextMenu does not have a ItemTemplateSelector property; only the top level XamContextMenu has this property.
I have resorted to using a ReactiveUI ViewModelVewHost and custom UserControls to represent menu items and separators, and while this works it seems way over the top for something that should be relatively straightforward.
Any suggestions would be appreciated.
Thank you David for reaching out to us today. I've discussed this requirement over with our team and unfortunately we do not have the infrastructure in place to accommodate multiple ItemTemplates.
You can suggest new product ideas for future versions (or vote for existing ones) at <https://www.infragistics.com/community/ideas>. Submitting your idea will allow you to communicate directly with our product management team, track the progress of your idea at any time, see how many votes it got, read comments from other developers in the community, and see if someone from the product team has additional questions for you. Remember when submitting your idea to explain the context in which a feature would be used and why it is needed as well as anything that would prevent you from accomplishing this today. You can even add screenshots to build a stronger case. Remember that for your suggestion to be successful, you need other members of the community to vote for it. You can also link back to this thread for additional details.
Let me know if you have any questions.
Michael DiFilippoSoftware DeveloperInfragistics, Inc.