- click ContextMenu. : ( ) ElementName CommandParameter.
, , , :
System.Windows.Data Error: 4 : Cannot find source for binding with reference 'ElementName=imgArena'. BindingExpression:(no path); DataItem=null; target element is 'MenuItem' (Name='mnuAddItem'); target property is 'CommandParameter' (type 'Object')
-, WPF , , .
, :
NameScope.SetNameScope(mnuGrid, NameScope.GetNameScope(this));
"mnuGrid" - .
After that, I was able to transfer my control as a parameter to my team, just like Beta Vulgaris did above.
For reference, my XAML looks like this:
<Image Name="imgArena" >
<Image.ContextMenu>
<ContextMenu Name="mnuGrid">
<MenuItem Header="Place _Entry" Name="mnuAddItem"
Command="{Binding AddEntryCmd}"
CommandParameter="{Binding ElementName=imgArena}" />
</ContextMenu>
<Image.ContextMenu>
</Image>
source
share