views:

46

answers:

1

When I execute a routed command, let's say:

ApplicationCommands.Undo.Execute(null, this);

WPF does some magic to find the proper CommandBinding on which it executes the ExecutedRoutedEventHandler.

Is there a way to get a reference to the CommandBinding (or at least to the handler) that would be executed?

It would sometimes be nice for debugging to know who is handling a command.

A: 

You can try to check the CommandBinding lists in:

       UIElement
       ContentElement 
       UIElement3D

ApplicationCommands are checking internally if sender has particular command in CommandBinding. In addition if sender is null then Keyboard.FocusedElement is assigned as sender.

klm_