I've bound a command to a button on a Ribbon control. The CanExecute method on the button gets called as expected but clicking on the button doesn't cause the Execute method to be called. The CanExecute
sets the CanExecute
property to true
- the button in question is enabled and clickable.
Has anyone else seen this behaviour before? If so how do I fix it!
EDIT:
CommandBinding commandBinding = new CommandBinding(StaticCommands.ThisCommand, ThisCommandExecutedHandler, ThisCommandCanExecuteHandler);
CommandManager.RegisterClassCommandBinding(this.GetType(), commandBinding);
CommandBindingList.Add(commandBinding);
StaticCommands.ThisCommand
is a RoutedCommand
with an input gesture of F5
.
Unfortunately I can't post any xaml because everything is wrapped up in another team's libraries. I am assuming that is correct for now. Also, using the keyboard gesture associated with the command (pressing F5
) causes the execute me开发者_如何学Cthod to be called.
There are no exceptions thrown, no messages in the output window, and snoop shows everything bound correctly. I'm really stumped.
This usually happens if the parameters dont match in type correctly... are you binding CommandParameter
of one type and accepting a different type parameter in the Command.Execute() call?
Fixed this by wrapping the RoutedCommands
in a RelayCommand
. I have no idea why that worked, but assuming there's a problem in the other team's assembly.
精彩评论