Basically it's not only you need to bind the command but you need to associate events as well. For example
<commandbinding command="ApplicationCommands.Close">
Executed="CloseCommandHandler"
CanExecute="CanExecuteHandler"/>
</commandbinding>
CommandBinding CloseCommandBinding = new CommandBinding(
ApplicationCommands.Close, CloseCommandHandler, CanExecuteHandler);
RootWindow.CommandBindings.Add(CloseCommandBinding);
private void CloseCommandHandler(object sender, ExecutedRoutedEventArgs e)
{
}
private void CanExecuteHandler(object sender, CanExecuteRoutedEventArgs e)
{
if (true)
e.CanExecute = true;
else
e.CanExecute = false;
}
For more how about reading the examples listed in the following MSDN article.
Commanding Overview[
^]