Saturday, March 11, 2006 1:21 AM
In XAML I can create and add a CommandBinding like this:
<Button Command="ApplicationCommands.Open">Open (KeyBindings: Ctrl-R, Ctrl-0)</Button>
What if I already have a binding to that command in the NavigationWindow that contains this page and I would like to use that binding instead of creating a new one ?
The reason I'd like to do that is because the handlers (in this case OpenCmdCanExecute and OpenCmdExecuted) are members of the NavigationWindow and I don't want to define new handlers in each diferent type of Page I create.
Actually, since the command will buble up, I could even not add a CommandBinding to the page at all and the handlers that reside in the NavigationWindow would still be called.
When using this approach the values for the parameters (sender,source and original_source) that the handler receives will all reference my inherited NavigationWindow instance. However, this doesn't work out for me because my handlers need access to the page instance, so the binding really needs to be added to the page binding list, but I only know how to do that in procedural code.
In a few words what I am looking for is a way, in XAML, to associate one CommandBinding with multiple elements. Does that exist?