I have Menu in my app. I\'m visualizing it using hierarchical data template:
The difference between the first and the second example in your question is that in the second code snippet you are binding MenuItem.Command
to the parent's data context, which has the RunOperationCommand
defined. Whereas in the first example with the HierarchicalDataTemplate
you are binding to the "local" DataContext, which is a menu item. It doesn't have the appropriate property, so the binding fails.
You have several options: