I have a control, on that control is a command called SaveToClipboardCommand. I want to bind a context menu item command to that command so that when i click it, the copy to clipboard command is executed.
<Control x:Name="Control">
<Control.ContextMenu>
<ContextMenu>
<MenuItem Command={"Bind to SaveToClipboardCommand here"} Header="Some Header" />
</ContextMenu>
</Control.ContextMenu/>
</Control>
The control (for argument sake) is defined like this:
partial class Control
{
private ICommand _saveToClipboard;
public ICommand SaveToClipboardCommand
{
get
{
if (_saveToClipboard == null)
{
_saveToClipboard = new RelayCommand(
x=> SaveToClipboard());
}
return _saveToClipboard;
}
}
}
I have tried using RelativeSource and ElementName based bindings but both are failing. Is what i am trying to do even possible?
Thanks!
{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type Control}}, Path-SaveToClipboardCommand}
– Ornamented