I would like to call an ApplicationCommand with a MenuItem-Click:
<MenuItem Header="{StaticResource MenuItemSave}" Command="ApplicationCommands.Save"/>
In my ViewModel-Constructor I inizialize my bindings with:
CommandBinding saveBinding = new CommandBinding(ApplicationCommands.Save, SaveCommand_Execute, SaveCommand_CanExecute);
CommandManager.RegisterClassCommandBinding(typeof(ViewModel_Main), saveBinding);
RegisterCommandBindings.Add(saveBinding);
Now I would like to handle the command, but it simply is not executeable. Even if it should be ALWAYS true.
private void SaveCommand_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
private void SaveCommand_Execute(object sender, ExecutedRoutedEventArgs e)
{
//Stuff
}
I have also tried to update all bindings after my init function:
CommandManager.InvalidateRequerySuggested();
But my MenuItem stays disabled.
Thank you!