views:

208

answers:

1

I have a static class called commands. One the RoutedCommands in it is called ConfirmNoPrint. I want to Execute it in code behind from my custom control like this:

Commands.ConfirmNoPrint.Execute(null, [WHAT_DO_I_PUT_HERE]);

In the custom control class I have an instance of Binding whose RelativeSource property is set like this:

_mainControlBinding.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(UserControl), 2);

Can I use one of the properties of _mainControlBinding to get the instance of IInputElement I need to pass as the second parameter of Commands.ConfirmNoPrint.Execute ?

The command binding for ConfirmNoPrint is the parent of my custom control, but it is in a different assembly. I can't add a reference to it since it would cause a circular reference.

I am barking up the wrong tree entirely?

A: 

Routed commands are, by definition, routed. If I understand your problem well, you just have to pass this as the second parameter of your command (assuming you're into the control class). The command will be bubbling up the visual tree until it encounters the command binding on the parent.

Julien Lebosquain
Ah, tx. Guess I was thinking to hard on this one. :)
Brent