1
My Viewреле Команда не стреляя по пункту меню нажмите
<Button.ContextMenu>
<ContextMenu x:Name="Conn_Context_button" Style="{StaticResource LeftContextMenuStyle}">
<MenuItem Style="{StaticResource LeftContextMenuItemStyle}" Header="{x:Static properties:ResourceWrapper.Dashboard_Connection_Delete}" Click="MenuItem_DeleteConnection_Click" />
<MenuItem Style="{StaticResource LeftContextMenuItemStyle}" Header="{x:Static properties:ResourceWrapper.Dashboard_Connection_Refresh}" Command="{Binding MyViewModel.RefreshCommand}" />
</ContextMenu>
MyViewModel.cs
public RelayCommand RefreshCommand { get; set; }
RefreshCommand = new RelayCommand(RefreshConnection);
private void RefreshConnection(object sender)
{
//My Logic
}
Здесь RefreshCommand не стреляет, когда я выберите пункт меню Обновить
Возможно, вместо этого использовать ICommand? – Whencesoever
Возможно, datacontext неверен, проверьте на наличие ошибок привязки на выходе. Если 'MyViewModel' является datacontext,' Command = "{Binding RefreshCommand}' будет решать это. – Natxo
Это не так просто: попробуйте http://stackoverflow.com/questions/9994241/mvvm-binding-command-to- contextmenu-item –