Click here to Skip to main content
15,887,746 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
<ContextMenu x:Key="ContextMenu">
  <MenuItem x:Name="MenuItemX" Header="2"/>
  <MenuItem Header="{Binding Header, ElementName=MenuItemX}"/>
</ContextMenu>


Using ElementName on a binding inside a context menu doesn't seem to work.
This link[^] describes one way to solve it, however my context menu has no name since it is in a resource dictionary. Any other suggestions?
Posted

I tend to use a variant of the technique described here[^].
 
Share this answer
 
It is a nice solution, however not to my problem at hand. If the code I was working on was developed in MVVM, I could have moved the code to the ViewModels, however for now I am stuck in the land of XAML and code behind.

As I see it, it is a bug by Microsoft that you as a developer can't bind to other UI elements inside a context menu. What I am searching for is a work around.
 
Share this answer
 
Comments
DaveyM69 30-Nov-10 9:18am    
As you have posted your comment as an Answer, Pete will get no notification that it has been posted. You would be better reposting using the Add Comment link below his Answer and deleting this.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900