Раньше я использовал
this.CommandBindings.Add(
new CommandBinding(ApplicationCommands.Copy, this.cmdCopy_Executed, this.cmdCopy_CanExecute))
, где cmdCopy_Executed - нестатическая функция, но я видел людей, использующих
static MyControl()
{
CommandBinding binding =
new CommandBinding(ApplicationCommands.Save, CommandHandler);
CommandManager.RegisterClassCommandBinding(typeof(MyControl), binding);
}
private static void CommandHandler(object target, ExecutedRoutedEventArgs e)
{
MessageBox.Show("Command Handled!");
}
, где CommandBinding статическая. Один из вариантов предпочтительнее другого?