Here is my code from the View.xaml.cs:
private RelayCommand _closeCommand;
public ICommand CloseCommand
{
get
{
if (_closeCommand == null)
{
_closeCommand = new RelayCommand(param => this.OnClose());
}
return _closeCommand;
}
}
public void OnClose()
{
Close();
}
And here is some code from my View.xaml:
<Window.ContextMenu>
<ContextMenu>
<MenuItem Name="menuItem_Close" Header="Close" Command="{Binding CloseCommand}" />
</ContextMenu>
</Window.ContextMenu>
When I run the program and select the close menu item, nothing happens. The CloseCommand code doesn't even get executed.
Command="{Binding ActiveVM.CloseCommand}"
– Persnickety